Monday, March 9, 2015

Arduino: Days 1 & 2

Blink
When first learning Arduino, we were tasked to try something simple like making an LED light blink for different intervals. For this, we started with the example Blink and modified the program to perform how we wanted it to. First we needed it to blink for one second on, one second off. Then we needed to change it to two seconds on, half a second off. Both of these tasks involved changing the delay time for each setting of HIGH and LOW. We also saw what it looked like with no delay (The LED stayed on HIGH). Next we needed to make a fun blinking pattern fo our light. It was helpful to see and manipulate this simple program to learn the basics of coding on Arduino. Here is our blink program.
Below is a photo of our blinking LED light:


 Blink Without Delay
Our next task was to manipulate the blinking of the LED without using delay. This way we would be able to control multiple functions at one time without pausing the entire program. For this, we decided our pattern would be for the lights to start at the off position and blink one at a time in a row. To do this we used if/else statements and && statements to tell our program how to behave. This is what our program looked like:


And here is a video of our blinking pattern:


Servo
Next, we connected a Servo to our Arduino and protoboard to see how we could manipulate that. Modifying another example program, it was easy to understand the way the coding worked for the Servo. We used intervals to specify when the Servo should turn and integers between 0 and 180 degrees to specify where it should turn to. We also played around with the delay to make it turn faster or slower.

Potentiometer
Next, we had to figure out how to control the speed of the blinking using a potentiometer. A potentiometer controls the amount of resistance let through the resistor attached to the LED light. This task was a little more difficult for my partner and me. We were able to control the brightness/dimness of the light, but not the blinking speed. On our program, we had the code directing to the Servo, which was not connected. After this had been resolved we had no trouble controlling the speed of the blinks. Often the hardest part is ensuring all the wiring is correct.
              
Above are two pictures of our setup for the potentiometer. This was the final arrangement after several trials (and errors).

On Friday we began to work with photocells and how we can manipulate LED lights and the Servo with photocell readings. A post on that and more Arduino findings to come...





No comments:

Post a Comment