Monday, January 31, 2011

Project 8 - RGB Mood Lamp

Project 8 was fairly straightforward... three LEDs will have their brightness and color mixed randomly to create other colors. I wired it up on the mini-breadboard that I stuck to the MakerShield... in a few of the photos you may see the GND wire (orange) moving from place to place as I test additional solder joints to make sure the various GND posts are working.

I didn't post a screen capture of the code here - I used the author's code with no modifications required.

I didn't get quite the results that the author achieved... either my LEDs are too bright (or not bright enough in some instances) or the incremental changes are just too difficult to see. Using a white piece of paper to diffuse the colors worked occasionally, but most of the time it was difficult to see any difference.

Still, I understand the code and how it works... this would be one crazy expensive mood lamp, however, if I chose to use an Arduino and 3 LEDs to make something like this!

Sunday, January 30, 2011

Building the MakerShield

I managed to get my new MakerShield put together - my soldering skills are not the greatest, so I'm not yet sure if I managed to successfully assemble it or not, but I followed the instructions here to get all the components mounted. Here are some photos taken as I slowly put the MakerShield together.

This type of circuit board, with the holes consisting of a small metal ring embedded in the board, gave me a lot of trouble. The solder seemed to want to "pull" down into the hole and not bead up, making it hard for me to tell if the solder joint was good or bad. I used my magnifying glass to inspect all the joints, but it's a flip of a coin as to whether I got them all done properly. I'm hoping that circuit boards like this are very forgiving because... again... my soldering skills aren't so great...

Update: I stacked the MakerShield on top of my Arduino and connected up Project 7 (3 LEDs fade in and out)... at least I know I soldered up pins 9, 10, and 11 properly!

Project 6 - Modified Project #2

I just could NOT get the second modification working using the Project 5 (and sometimes Project 6) code... no matter how I modified it, I could not seem to find a way to tweak the code just a little bit to "bounce the ball." My best guess was that it would involve some sort of counter that would limit the value that CurrentLED would count up to each time (reducing it from 9... to 8... to 7...) but again... no luck with that.

So... I decided to simply hard code it to do what I wanted. I kept the array (see screenshot of my code) but got rid of much of the variables, including the CurrentLED variable, and went straight to a set of embedded FOR loops that would first loop 9 times (for nine LEDs - the ball bouncing up)... then 1... then 2... I created a variable called bounce that would simply decrement in the code every time the second loop (the ball dropping) finished. Probably not the most elegant solution, but it worked. You can download my code modification here.

I welcome my readers to share their code if they managed to perform the 2nd modification on page 58 using a different method... I'd love to see a few other programming techniques if anyone wants to share.

Friday, January 28, 2011

Shopping List - Jan 28

I sat down today to go through the book and start building a shopping list - I was hoping to be able to buy a large portion of the required components from a single source. That's not going to happen.

It's very aggravating... sites like seem to have everything but it's like searching for a needle in a haystack to find exactly what you want - you can't go by the picture and sifting through dozens of data sheets gets old really fast.

Then you find sites like that have the sorriest search engines around. To top it off, I wasn't finding anything I needed on allelectronics and shut down that website completely after about 4 or 5 dead end searches.

The most success I had was at - I found a large percentage of the parts I need (at least up through Project 23, I think) and placed an order to save on shipping. I've updated the Projects Spreadsheet with this purchase. It may look random and it likely is... there are still a LOT of holes left between Project 8 and Project 23.

Two of the most difficult items to find are the 8x8 Dot Matrix Displays that will come later in the book - one is common anode and the other is common cathode. I finally managed to track them down from but the shipping alone is more than the combined price of the 2 items. I hate when that happens. I'll ask my readers to please help if they find a cheaper/alternative location for these parts... I just don't want to spend hours and hours trying to save $0.50 or so here and there on components and I don't want to drive all over Atlanta looking for parts.

On the Projects Spreadsheet, I've included all the parts #s and prices... hope that helps some of you.

More shopping lists to come, I'm sure...

Project 7 - Pulsating Lamp

I'm still working on the modification to Project 6 that will make the LEDs behave like a bouncing ball (see page 58), but so far I haven't figured out the proper code yet. (Please don't tell me - yet - as I want to try and figure this out on my own.)

In the meantime, I've moved on to Project 7 here which uses a bit of my least-favorite subject in high school - trigonometry. (Sorry math-teachers... I loved Algebra, Geometry, and Calculus, but Trig was my kryptonite...)

Project 7 calls for a single LED, but I thought it'd be fun to throw a few extra in the mix so I wired it up with 3 LEDs - green, red, and yellow. I also modified the code by adding in some additional variables (yes, I could have used an array and a loop for assigning the pins to OUTPUT mode, but with only 3 LEDs it was just as fast to create 3 variables and copy-and-paste some of the original code).

I also got to use my new mini-breadboard and the flexible jumper wires I ordered from last week. The MakerShield is very cool but it's a DIY device, so I'll be soldering this weekend to get it operational and ready to use... will post pics when done.

Below is a video of the pulsating LEDs... the text calls for a green LED but I found the green LED gave me the worst results... the red and yellow LEDs have a very nice fade in and out and the green one just looks weak (your results may vary). Could be a cheap LED... who knows?

I think the key concept to take from this project is to understand PWM (and how the sine function is used in the code...). I got lucky in the sense that I wired up my 3 LEDs using pins 9, 10, and 11... I didn't realize that the PWM pins were limited to 3, 5, 6, 9, 10 & 11. If I had used 10, 11, and 12, I doubt I'd have gotten the results I wanted. (As a matter of fact, I'm going to pause here and rerun the project and change the code to use pin 12 for the yellow LED... let's see what happens... 2nd video will show the results.)

Wednesday, January 26, 2011

Project 6 - Modified Project

On page 58, the author provides a couple of extra exercises that are modifications of the Project 6 code. I decided to try my hand at the first one (second one to come) and gave it some thought today. The goal is to take an even number of LEDs and have the outer edges light up and then continue inward to the center of the line and then bounce back... so an even number of LEDs will work best... for this modification, I removed an LED so I have a total of 8 LEDs in the circuit.

I'm certain there are dozens of ways to do this - Project 6 uses a single array to control all the LEDs, but it occurred to me that in this exercise, I basically have two separate arrays running, each the reverse direction of the other. I took the code for Project 6 and modified it by breaking the initial array into two arrays (see two screen captures here for entire code). By doing this, I would also now require two directional variables and two currentLED variables to track the two current lighted LEDs. (Hope this makes sense...)

After trying to download the code to the Arduino, I encountered numerous syntax errors that were easy to fix (most of them involved forgetting to change a variable name to the new variables I created)... after fixing the syntax errors, the code downloaded and I was very happy to see it working as I hoped it would... see video below. (You can also download my modified program by clicking here.)

I left the 5k potentiometer in the mix as it allows me to control the speed of the two LEDs that light up... a very cool effect!

Tuesday, January 25, 2011

Project 6 - Interactive LED Chase Effect

Project 6 uses the same circuit from Project 5, but this time I added a 5k potentiometer to the mix (the book calls for a 4.7k, but I already had a 5k in my parts box from the Make: Electronics blog) and modified the code (again) to allow for 9 LEDs versus 10.

Cranking the potentiometer all the way to the left causes the LEDs to blink on for about 1 second before all LEDs are turned off and the next LED is turned on. Turning the potentiometer all the way to the right reduces the time between the lighting of the LEDs to almost zero, and even the flicker (caused by the turning off of all LEDs) isn't even noticeable and the LEDs just appear to be solid and constantly lit.

I'm going to play around with the code now and try my hand at the two extra experiments listed on page 58.

Monday, January 24, 2011

Project 5 - LED Chase Effect

I started off this project an LED short - it calls for 10, but I only have 9. This was fortunate as it forced to go through the code again and modify it for only 9 LEDs. I'm including a screen capture of my modified code here, but pay attention to the loops (for statements) where I had to reduce the count by 1... since we start counting at 0, the initializing loop (setting all pins to OUTPUT) will only count up to 8 (for a total of 9 LEDs).

But that's not the only place where the code had to be changed. Later in the process the direction variable is changed to -1 so the LEDs will light up in reverse... once again, the code must be modified so that the variable currentLED is set equal to 8.

A fun little project and reminded me of a 1 hour soldering job I took on to create my 3 year old son the Monster-B-Gone... a silly little project box that flashes a set of green LEDs and indicates the room is clear of baddies. It's funny that it took me over an hour to create that box but only about 10 minutes or so to wire up and program Project 5... (would have taken just a few minutes longer if I'd typed the code in manually instead of opening the author-supplied file).

You can easily modify this program for any number of LEDs (well, up to the maximum number of digital pins on the Arduino that are free) so if you don't have 10 LEDs, feel free to wire it up with 5 or 6... even a mix of colors will still get the point across if you examine the code and make an effort to understand what's happening.

One final note about this project - if you go back a few chapters where the author explains the basics of LEDs, you'll read that the Anode end will usually be a longer wire and the Cathode the shorter. Well, that doesn't hold up for every LED. I've taken a picture here of an LED resting on the flat notice and if you look closely, you'll see that it has the longer leg - it's a small difference, but it's definitely longer! All 9 LEDs in this bag are the same - long leg matches up to the flat notch. Check your LEDs and don't just assume that the longer leg is for the Anode side.

Saturday, January 22, 2011

Project 4 - Interactive Traffic Lights

Project 4 adds a few new components to the ones used in Project 3 - an additional red and green LED, more resistors, and a pushbutton.

I wired up the circuit but made a few changes from the ones seen on page 39. First, rather than move the existing red, green, and yellow LED wiring from its original positions in Project 3, I left them alone and instead inserted the new red and green LEDs to digital pins 12 and 11, respectively.

The pushbutton was connected to digital pin 2 as specified in the wiring diagram, and I removed the GND jumper wire (from the digital GND pin) and ran two wires, one from 5V+ and the other from GND (both in the Power section of the Arduino UNO). (If anyone can explain why the GND couldn't be left alone, please let me know... if you wire V+ (5 or 3.3) from the Power section, does that require that you also use the GND pin under the Power section? This wasn't explained...)

One other thing you might notice if you look carefully at the wiring diagram for Project 3 and compare it to Project 4 is the placement of the resistors. I didn't catch this at first, but in Project 3 the resistors are all wired up on the anode side of the LEDs... but in Project 4 they are wired up on the cathode side of the LEDs. My basic understanding of electronics tells me this isn't an issue... the resistance is applied in the circuit whether it's sitting in front of or behind of the LEDs. Current just "feels" the resistance and doesn't "care" whether the resistor is on the anode or cathode side of an LED. (Maybe I'm wrong, but the circuit does work with the LEDs left on the anode side of all the LEDs.)

Finally, I chose to use the author's supplied code this time rather than type it all in... all I had to do was go in and fix the integer variable values for the pins (see first screen capture). The other change to the author's code was the removal of the yellow light after the pedestrian light goes from green to red. In the USA, when the crosswalk starts blinking (warning pedestrians that it will change to Don't Walk) and finally turns to red, there's usually a slight pause before the traffic light (for cars) turns green. There is no yellow light that pops up for the cars, so I removed this from the code and the video below will demonstrate how the new code works. Note also in the video that just after the pedestrian light turns red, the pushbutton is disabled for 5 seconds - I push it a few times to try and trigger it but no luck.

The questions I encountered (and described above - use of Power section GND versus the digital pin GND and the placement of resistors on anode or cathode side of LEDs) are ones I will try and find answers to... I'd hate to damage my Uno by wiring up something improperly in future projects.

(Update: I ran down the checklist of items on page 49 to make certain I had an understanding of the list of Subjects/Concepts - all good.)

Friday, January 21, 2011

Project 3 - Traffic Lights

I modifed Project 3 just a bit - first off, the book uses a UK traffic light system so I changed it to the US version (red... green... yellow... red... ) and I changed the LED delay from 10000ms to 5000ms (5 seconds) for faster switching between LEDs (for video purposes).

A couple other notes - in the book, the breadboard seen in Figure 2-6 has the left side power/ground columns shown with Ground (blue line) closer to the center of the board and the High/Pwr (red line) on the left and furthest from the center of the board. This doesn't match my breadboard (no big deal) but if you look at the photo here you'll see that I also had to modify the wiring to reflect that... everything else was the same. (Technically, I guess the column you use really doesn't matter as long as you are consistent, but I've tried to be consistent in using a breadboard by using the red column for V+ and the blue column for GND.)

One simple mistake I made at first was inserting the yellow LED incorrectly... I thought I had placed the anode end of the LED in the same row as the resistor, but when the LEDs didn't light up properly, I pulled out the yellow and found the flat/anode side of the LED inserted incorrectly. At some point I had clipped the wires on the yellow LED to the same length... so always check that and make certain that the flat/notch side of the LED plastic dome is connected to GND or LOW.

One last thing - if you look at my code screen captures, you'll notice that, yes, I'm not typing in the comments. Sorry. I'm not really saving this code in a folder, so I'm not taking the time to enter comments... may do that later when the code gets longer and more complicated.

UPDATE: Original video had sound problems... fixed now.

Thursday, January 20, 2011

Project 2 - S.O.S. Morse Code Signaler

Project 2 uses the same circuit from Project 1, just different code. The code on page 32 is fairly easy to follow, but this is the first time I've encountered the shortcut code for incrementing (x++). My past programming languages include BASIC, Fortran, and Pascal... old school, yes. So I understand the theory of loops, conditionals, etc... and the conventions of this new language aren't confusing me (yet).

I entered the code and ran it - video below. Not much here for experimenting and variations other than either changing the code to some other word or changing the flashing speed and delay times. I did try my hand at rewriting the code with the For loop running in reverse... (see screenshot of my modification). Was guessing about the x--, but it worked... I simply changed:

for (int x=0; x<3; x++)


for (int x=2; x>-1; x--)

Why did I do this? Just a hunch that it would work the same way, but actually testing it will stick with me more than a simple mind exercise... I'm hoping to find ways to modify other projects as they happen and try and learn a bit about the programming language and/or the Arduino... more to come.

Project 1 - LED Flasher

Project 1 is as straight-forward as they go - connect up an LED with a small resistor and program the Arduino to flash the LED on and off. The circuit is very simple but it's the code where I'm finding myself spending the most time reading and examining. I'm not a programmer by any means, although I've had some programming classes in the past. That said... I'm not a programmer! So this C language is a bit confusing with all its void-this and setup-that stuff.

For now, I'm just going to accept that this is the format and requirements for programming in C (for Arduino) and if I find later I need more advanced training, I'll dive into C programming... but not yet. Having worked through the Make: Electronics book, I feel I've got a solid grasp on the electronics portion - voltage, resistance, current, etc... and how many of these components work... still, it was a short read to go back over the details of how to read a resistor's bands and how to find the Anode (versus Cathode) of an LED.

Off to a good start... the Arduino appears to be functioning properly and the IDE is installed properly, so at least I won't have to troubleshoot trying to get moving on the projects.

Two videos below - first is just the plain code seen on page 23 (I hope my page 23 of the PDF file I'm viewing on the iPad matches the page 23 in the print book - someone let me know if it doesn't and I'll stop using page numbers). The LED blinks on and off in 1 second increments. The 2nd video is where I changed the HIGH and LOW delays to 250ms.

Wednesday, January 19, 2011

Getting the IDE (Software)

Just visited and grabbed the latest version of the Arduino IDE, version 0022. The instructions in the book vary based on operating system, but I'll be running it on a Windows Vista laptop (yeah, yeah... I know...) so the short walkthrough here might not match up to your installation.

After unzipping the 0022 folder, I attached my Arduino to my laptop with the USB cable (again, following the instructions here) and... just like the instructions said... Windows wasn't able to identify the device.

I opened up the Device Manager (see screen capture 1) and the device has the standard exclamation point error icon. Not a problem...

A pop-up window finally appeared that allowed me to specify the driver file locations (see screen capture 2). It found the folder and the correct driver and after a few "Yes, I give you permission" clicks, the installation began and finished with another window saying "The software for this device has been successfully installed." Yay.

Next, I clicked the Tools menu and selected the Uno from the list of available Arduinos. (It was the default, actually.) Next, I clicked the Serial Port selection and selected COM5 (which matches the COM port in the Device Manager assigned to the Arduino).

Finally, time to run a test sketch. Clicking File, I selected the Examples option and chose the Blink sketch. After a few seconds where the sketch downloads to the Arduino... see video.

Tuesday, January 18, 2011

Arduino in Hand

The mailman was running late today (usually delivers around 2pm but didn't show up until well after 5pm)... and tucked inside a brown protective box was this nice little package, complete with "Made in Italy" sticker sealing the little foldaway container. I love product packaging, especially foreign products, and this one is very efficient.

Open the container and inside is a "Thank you for supporting..." foldout containing info on how it was manufactured, tested, and packaged. (Apparently "buying this board helps us to restore and protect 0.5 sqm of forest in Madagascar" - I should buy some more!)

A small sheet of stickers ("DIY" - "Open Source" - etc.) sits on top of the little board. I've seen Arduinos before but I was still very surprised at the tiny size of the Uno. It's still using the socketed Atmel chip - if you haven't heard, apparently Arduinos are going to be moving away from this to the small surface mount chips... not sure if this is true but it's what I've read elsewhere.

Anyway... it's in my hands (hand) now... and I'm itching to get started...

Still waiting...

I'm sure the the snow/ice storms we had in Atlanta last week slowed the mail down... I'm still waiting on my Arduino Uno to arrive, but so far... zip. I've taken this opportunity to do some spring cleaning of my work area - I've got dozens of unknown resistors scattered across the desk that I've now metered and filed away in the appropriate storage bin... same with some capacitors and a handful of other miscellaneous electronic components.

I'm kind of shocked at the amount of stuff I've collected over the last year as I worked through Make: Electronics... forgot I'd bought some of these things!

In the meantime, the folks over at Make have created an Arduino-focused webpage that has some nice links - projects, tutorials, videos, etc... scroll down the page a bit until you see the Resources section and spend some time browsing there... a lot of good stuff. I'm a big fan of the website, so be sure to click on that link as well - they've got hundreds of projects!

Monday, January 17, 2011

Some Extra Purchases

Before this blog began, I documented my experiences working through "Make: Electronics" by Charles Platt. During that time, I built up quite a collection of components - resistors, capacitors, buttons, switches, etc. I also learned to use a full-size breadboard and I cut and trimmed my own jumper wires for most of the 36 experiments in that book.

Scanning through "Beginning Arduino," I can see that there are a lot of components that I won't need to purchase this time around. But one of the things I've noticed in the book's projects is the use of the breadboard in conjunction with the Arduino. While that will certainly work, I was reading through the latest Make magazine (Vol. 25) and noticed they've released a new shield for the Arduino called the MakerShield. In addition to some of the built-in features, one of the features that caught my eye was the center section that was designed to support a mini-breadboard. So I went ahead and purchased the MakerShield and the mini-breadboard (white -for better photographs I hope) - my desk is so cluttered, so maybe this will help keep many of the projects inside a smaller boundary.

While I was placing my order, I also saw these great jumper wires... flexible but the exposed ends are stiff for inserting into the breadboard. (I've added all these items to the Projects Spreadsheet.)

Friday, January 14, 2011

Why "Beginning Arduino?"

I have a rather large collection of URL links stored in an Arduino-tagged folder... printed out, it'd probably fill a couple notebooks. The problem with all this information is one we've all encountered when it comes to the Web - too many sources, too many dead pages, and too much to sift through. That's why I still heavily rely on books when I wish to learn something new.

My Arduino book collection is rather small. I own the following:

1. Getting Started with Arduino - okay, but extremely simplified and short.
2. Practical Arduino - daunting and pure information overload - really written for an Arduino expert, IMO... or at least someone very familiar with both electronics and Arduino programming.
3. Beginning Arduino - only read 1/2 so far, but this is definitely the book!

Update: A quick look at Amazon shows they only have 4 copies left as of 11:40EDT Jan 14th. Get your order in quick as it sometimes takes weeks for reprints to arrive.

Update: A quick look at Amazon shows they only have 2 copies left as of 4:30EDT Jan 14th. Get your order in quick as it sometimes takes weeks for reprints to arrive.

No insult to the first 2 books, but they're not what I'm looking for when it comes to hands-on learning. The number of books available on Arduino seems to be growing fast, but I just don't see anything else available that appears to meet my needs. O'Reilly has some books on the programming side, but my experiences with their books leads me to believe they're more likely to be good reference books and not teach-yourself material.

If anyone knows of any other Arduino books that might make good references, let me know... I'd rather spend my money now on components and acccessories, but if there's a book I'm missing that will make this experience more enjoyable (or at least successful), I might consider purchasing it.

One Disclaimer: I write tech books for a living, so I have relationships with many book publishers that allow me to sometimes get a Reviewer Copy of different titles. My digital and print copies of the "Beginning Arduino" book came courtesy of Apress (print copy, however, seems to be caught up somewhere in the USPS labyrinth), a great publisher for whom I've written quite a few books over the years. That said, my intention is to provide an un-biased review of the book, including feedback, positive or negative, about my experiences.

Thursday, January 13, 2011

Some Current Arduino News

Just some random Arduino news that seems to all have occurred this week - if you're unfamiliar with the Arduino, the video (#1) is very helpful... and Make Volume 25 (#2 below) is also a good read:

1. Arduino The Documentary was released.

Arduino The Documentary (2010) English HD from gnd on Vimeo.

2. Make magazine Volume 25 focuses on the Arduino. (I'd estimate 50-60% of the magazine is directly related or involves the Arduino in some manner - I have the PDF/digital version on my iPad, but the print version should be out by Jan 25.)

3. Beginning Arduino from Apress hit the shelves (once again, however, I got the digital version)

4. Even The Ben Heck Show has coverage of the Arduino in this week's episode!


Welcome to Hands On - Arduino!

The purpose of this blog will be to provide me a space to document my experiences (via text, photos, and videos) as I work through the new book, "Beginning Arduino" by Michael McRoberts.

The actual work isn't likely to start for a week or so - I've got some housekeeping issues to take care of here before I begin, so please excuse me if the blog "moves around" a bit over the next week as I tinker with the layout, add links, etc...

If you're thinking of following along, feel free! I'd love to have other contributors sharing their results with me - post your comments in the proper Project posting(s) and share with everyone else if you can. Just grab a copy of the book, order yourself an Arduino Uno, and get to reading.

More to come...