Monday, February 29, 2016

Arduino Circuit with Temperature Sensor TMP36 - Temp Reading Functions as LED Switch

I finished building the basic circuit for controlling a LED bulb with a switch control (the white jumper wire in the photo below).


After disassembling this switch circuit, I decided to create a circuit where an LED bulb the switch for on/off would occur when the room temperature would drop below a specific number. I've found that the TMP36 sensors are not terribly precise with air temperature readings. They can frequently be off by over 20 degrees with a very basic circuit that runs off the 5v Arduino output. I searched for an solution to increase the TMP36 sensor's accuracy and found this alternative circuit on the Adafruit site (scroll down to the "Getting Better Precision" section) which utilizes the 3.3v reference voltage as ARef. I then added a basic LED bulb to my circuit and added code that would turn the LED on if the temp sensor's reading dropped below a 210 voltage reading (approximately 66 degrees Fahrenheit).

Here is the circuit diagram


Here is the Arduino sketch's code


int TempSensorPin = A6; //analog pin 0

int YellowLED = 6; // The LED attached to pin 6 will be called GreenLED

void setup(){

Serial.begin(9600);

pinMode(YellowLED, OUTPUT); // sets GreenLED Pin as an output sending data or current out

pinMode(TempSensorPin, INPUT);

// Set pin A5 to use as a power pin for the light sensor for LilyPad only as per Tutorial - I did not use these two lines as I powered with + not A5

pinMode(A5, OUTPUT);

pinMode(A5, HIGH);

}

void loop(){

int TempSensorValue = analogRead(TempSensorPin);

Serial.print("Temp value is:"); // Print some descriptive text and then the value from the sensor

Serial.println(TempSensorValue);

if (TempSensorValue <450) { // if the SensorValue is higher or lower than a certain value

digitalWrite(YellowLED, HIGH); // turn the LED on

} // this brace closes the if statement

else { // otherwise

digitalWrite(YellowLED, LOW); // turn the LED off

} // this brace closes the ELSE statement

//delay(200); // This is too slow down the process adjust as necessary

}

Sunday, February 14, 2016

Plugging In the Pi T-Cobbler Plus and Attempting my First GPIO Project

So I wanted to get the physical challenges out of the way first before I even attempted to boot up my Raspberry Pi. I took a look at the Pi T-Cobbler Plus breakout cable and was asking three initial, pressing questions:
1. Does it matter if the cable is rotated the wrong way when plugging it into the RPi?
2. Can the RPi be up and running when I plug in the data cable or will it damage the motherboard?
3. How do the pins of the Cobbler fit into a breadboard?

I tried to briefly tap into my common sense resources... if the data cable was attached to the RPi GPIO pins with the cable forced to run over the motherboard, that would equate to a bit of silly design work on Adafruit's side since it is called a "break-out cable" not a "break-in cable".

I have to admit that this photo on the Adafruit Pi T-Cobbler Plus page helped me quickly figure out the correct connection decision.

It turns out these were very, very good questions to ask. So with the common sense voice inside me head shouting, "Do some more research before you ruin your Pi!", I found this this helpful video which illustrated that the quickly explained the potential damage you could do to your RPi if you don't pay attention to the

Once I didn't witness any smoke or detect and burning circuitry aromas emitting from my RPi I felt confident that I didn't fry my Pi. I moved on to YouTube to search for some tutorials to test out my new breakout kit... This video is what I found:



I felt lucky to find such a fantastic 2 part tutorial on using the RPi GPIO and Python code to control On/Off and delay commands for LED lights. I dove in and gave it a try.

A precursor to my rather disjointed video documentation of my newbie adventure: I haven't figured out how to do VNC to do a proper screencast recording on a remotely connected PC yet, please be prepared for some motion sickness.

ust

Overall, I am astounded by the ever-growing sea of resources for just-in-time, on-demand, community-based learning which is called the Internet. I can't imagine progressing forward at such a fast pace with my independent learning without the online resources I discovered within seconds of typing in various keyword searches.

Up next, I've had this relentless, niggling urge to see what is out there in cyberspace for interfacing Arduino (another fantastically versatile maker-movement invention) with RPi. One step at a time. This successful Kickstarter project has captured my attention.

Wednesday, February 10, 2016

Arrival of Raspberry Pi 2 Model B

I'm eager to get Jessie installed on the Pi 2 Model B that arrived in the mail today. Once I unboxed the computer, I decided to house it in the clear Plexiglas case I had an older Pi Model B+ in. It was a breeze to extract the older board out, but being an extreme un-handyman sort, I of course had to struggle for over 30 minutes to get the new Pi 2 to fit snugly into the case. Note to self: slip the Pi board into the the bottom piece of the case first (slipping the board under the 2 plastic notches at the micro SD slot end). If you ever have difficulties getting you board to sit level and flush in the case and the top won't completely snap shut, look for those notches to pop the Pi board into first, then the top half of the case and the lid should fit perfectly.

After downloading Jessie, the newest Raspbian distro, I followed the installation instructions on raspberrypi.org. After formatting the micro SD card and installing Jessie with Win32DiskImager, I'm ready to finally boot the "micro" computer. I'm really hoping that the upgraded processor and 1 GB of RAM will actually make it a usable computer.



45 minutes (or so) later...
Jessie booted up just fine, and I'm thrilled to say it passes the "usable computer" test. Overall the Pi 2 is at least 3 to 6 times faster than the Pi Model B+. I did hit an odd bump in the upgrade road. When I opened up the terminal and put in the upgrade command, sudo apt-get upgrade I got the following error message.



I am using a 16 GB micro SD card, so I was perplexed. After Googling the error message:
E: You don't have enough free space in /var/cache/apt/archiv, 
I found the following RaspberryPi.org forum post to get me out of the jam. Thanks to the simple fix of opening preferences, then Raspberry Pi Configuration control panel and choosing "Expand File System", I was finally able (after a reboot) to execute the massive upgrade download.




The terminal is now speedily scrolling away with the upgrades. I hope I can eventually start tinkering with the Pi 2 before dinner. Patience is a key, mandatory character trait for RPi users.

20 minutes later...
One last bit of house cleaning/maintenance was needed. I noticed in the terminal that "The following packages were automatically installed and are no longer required: libdrm-freedrenol libdrm-nouveau2 libdrm-radeon1 libelfi libllvm3.5  Use 'apt-get autoremove' to remove them.

Finally ready to explore the Pi 2.



Monday, February 8, 2016

Tinkering with Sonic Pi tutorial on Raspberry Pi

Sonic Pi comes bundled with Raspbian (I'm currently running Wheezy); you can find it in the Raspbian menu under Programming.



Sonic Pi offers basic tutorials in its help section on entering specific commands to generate synthesizers and manipulate sound samples (both included within the program). I tinkered with various commands such as sleep (pauses), amp (to control volume of individual sounds), sustain, release, panning, and loops with randomizing functions that will repeat the until the stop button is clicked. One very nice feature of this program is the log window to see the script running in real time. Sonic Pi utilizes a version of Ruby programming language. I think I'll definitely start to tinker a bit more in upcoming days.




Here's the saved project's code:
use_synth :prophet
play 70, pan: 1
sleep 0.5
sleep 1
play 75, pan: -1
sleep 0.5
use_synth :saw
play 49
play :f4,release: 5, pan: 1
sleep 0.4
play 61, amp: 1.9
use_synth :tb303
play 70, pan: 1
sleep 0.5
sleep 1
use_synth :zawa
play 75, attack: 2, pan: -1
sleep 0.5
sample :drum_cymbal_open, attack: 0.01, sustain: 10.3, release: 10.1
use_synth :saw
play sample :ambi_glass_rub, sustain: 12, rate: 0.5
play 49, sustain: 3, release: 5
play :f4, amp: 0.8, pan: 1
sleep 0.4
use_synth :sine
loop do
  sample :perc_bell, rate: (rrand 0.925, 0.2)
  sleep rrand(0.2, 2)
end


Friday, February 5, 2016

Mobile Coding Apps for Learning Programming On the Move

I installed 3 apps on my Samsung Galaxy Note phone, and I have to admit that I'm very excited to have some great code learning tools to access on-the-go. So far I've pretty much relied on desktop and laptop applications to start learning the basics of code languages. The only mobile app I've used up until recently was Code Academy on my iPad... which I found helpful, but lacking a bit on the interactive end of things. The three new mobile apps for Android devices I have begun exploring are SoloLearn - Learn Java, QPython, and Lightbot: Programming Puzzles. Even if you don't have a very powerful, newly released smart phone, I don't think any of the apps have very demanding system requirements to run well. SoloLearn has free iOS and Android apps, plus a website. QPython, also free, appears to be just for Android devices, and Lighbot: Progamming Puzzles is available at a small price for iOS, Android, Kindle, and has applications for Windows and Mac computers.

Lightbot: Programming Apps & Applications


Lightbot impressed me. I have to admit I was pleasantly surprised by design of the app. The sounds, simple 3D graphics, and overall playing experience were engaging. I didn't feel like I was bored or frustrated with playing an oversimplified, rudimentary game. The intensity of the puzzle challenges quickly elevated in difficulty when I reached the last few puzzles in level one. I'm halfway through the "Procedures" section, and the app has successfully taught me the concept of  nesting code procedures to more effectively cope with repeated tasks. Overall with producing a gaming/puzzle app that also incorporates a very solid introduction to some basic coding concepts: procedures, overloading, loops, and conditionals.

On my Galaxy Note 4: Lightbot: Programming App - "Procedures" Level


If you want to give these apps a test drive, I recommend you start with Lightbot to get an entertaining and gratifying intro to coding concepts without having to deal with grasping the text-based code that runs the puzzles.

When you feel ready to get a introductory summary to how the different coding languages function and are used for different programming tasks, start moving through the SoloLearn apps and/or courses. I truly enjoyed reading about concrete information about the basic functions of Java for web design. The SoloLearn app clearly defined the different roles that HTML, CSS, and Java play within web development and coding for interactive websites.

SoloLearn Java Course for Android - Mini-lesson then Quiz

QPython was the most interactive and intriguing of the three apps I installed today. The app lets you immediately start editing lines of code within very simple scripts (similar to "Hello World"). I am very eager to keep moving forward into the lessons this app has to offer. The extremely short and concise scripts fit nicely on smart phone screens and are not overwhelming for newbies. A great introduction to text-based coding where you can load and run the script right on your phone.




To sum up my experience with these three apps, I found that they all blended together an amalgamation of great introductory learning for programming languages. All three apps take a very different approach to easing a text-coding newbie like myself into actively using Java and Python.