Now that we know that the Arduino is working, we can start to play with it. Hardware required
![]() As I wrote in the main page, you really should have a breadboard for prototyping. I have the Liquidware doubletall extender shield with three small bread boards stuck to it. In this photo I have some circuits installed, but you can see the breadboards on the shield. The shield needs to be placed on the Arduino and it can only go on one way, so its super easy. Just line up the pins and gently press them together. In these two photos you can see the pins lined up, and the extender installed. Ignore all the wires on my breadboard. :) ![]() ![]() Now we will wire up a photocell to measure the ambient light, for this project I find a flashlight to be pretty useful. :) We will wire up this circuit on our bread board. ![]() Look at your combined Arduino/double tall shield, with the USB port facing you, the pins on the left, farthest away from you are the power pins, next are the analog I/O pins, then the digital I/O pins. The pins on the right or identical, BUT reversed top to bottom. The breadboard has a series of holes in it with a trench down the middle. The holes are connected horizontally on each side of the trench, but NOT across the trench. So if you set your multimeter to check continuity, and put the probes on two holes next to each other, you would register a connection, lets call that a "row". With that in mind, we begin...
![]() The photo shows the green line plugged into ADC 0, sorry. It should be 5 down (to the left in the photo) in ADC5. See the wire, resistor and LED on the left? Ignore them, they are for a different project. :) Now plug your Arduino into the USB port on your computer and fire up the Arduino IDE. In the IDE set you baud rate to 57600, the setting is a drop down above the serial monitor. Paste the following code into the Arduino IDE. Click the "Upload to I/O Board" button to compile the code and upload it to the Arduino. The compile and upload will take several seconds. When its done, click the button to the the far right of the toolbar, "Serial Monitor". The console should say "Starting photoresistor tutorial..." and then start streaming lines of numbers in the range of 0 - 1024, 0 being the brightest and 1024 the darkest. Does that seem backwards? It does to me, so to reverse (or correct) the mapping (0 is darkest, 1024 is brightest) swap the resistor and the photocell. Turn lights on and off, shine the flashlight on the photoresistor and you will see the numbers change. In this configuration we are using a voltage divider to measure the voltage. As we get more light on photoresistor, its resistance increases, so the measured voltage goes DOWN (or up, depending on if you swapped the photoresistor and the resistor) It doesn't work! Bummer.. Well, check all your connections, compare them to the photo. If you did a copy and paste of the code, then the problem almost certainly has to be in the wiring. |
Arduino >