Saturday, March 7, 2015

Arduino, Day 1

Day 1 of our interactions with our Arduino package.

This day focused on our understanding of a breadboard and circuits in relation to the Arduino, and instructed us on two basic Arduino template programs.

The first step before connecting a circuit to the Arduino was to understand how the Arduino functioned. We first completed an assignment that would make the LED embedded in the board to blink at a specific rate.

The comments (gray text following the double backslashes "//") were key to our understanding of the commands we needed to accomplish our task.

"pinMode(13, OUTPUT);" designates the output of electricity at an outlet, specifically outlet 13.
In our loop, the "digitalWrite(13, HIGH);" causes the LED light at outlet 13 to be fully on, level "high." The next step causes the light to turn off, thus being at a "low" state.

The result was a steady blinking of the LED light with the smallest of pauses, but these pauses of "low" levels were so small that our eyes couldn't detect the LED going off.

--

After we learned about the connections of breadboards and the proper way to hook up the Arduino to the resistors (through intermediate cables), we began to look at a very basic program called "Blink."

Blink:

Here, the template is shown. Basically, the Blink program designates terminal 13 as the output and turns on the LED high for 1 second (the program is written for milliseconds, so 1s = 1000ms). Then it turns the LED off (low) for 1s. This template showed us what the command "delay" does. Delay holds the preceding command for the specified amount of time listed.












Here is our first modification of the Blink program template. We had the LED go on for 2 seconds, off for half a second, on for half a second, and off for two seconds. To do so, we modified the loop to turn the LED on twice and off twice, alternately. We varied the delay value to adjust the intermittence.








The video of our modified Blink program



We were then assigned to create a Blink program for two LED indicator lights.

We built a circuit using terminal 12 as the other output. The connected LED light responded to the commands pertaining to "12." We utilized the delay command to alter the period between the LEDS turning on and off. This modification had the 13 LED turn on for 2 seconds then off, while the 12 LED came on for half a second. Then they were both off for half a second. They both turned on together for one second, then off for one second.








Our next challenge was to create a "cool pattern" using the Blink program and 4 red LED lights. We designated terminals 12, 8, 7, and 4 as outputs, then used the delay command to stagger the switching on/off of each individual/pair of lights. Ours is shown below.


No comments:

Post a Comment