Thought it doesn't show it in the picture, one side of the LED was connected to Pin 13 and the other side was connected to the resistor and then the ground. We then had to upload the program, BLINK onto the Arduino and play the program.
It worked!! We then had to change the program to make a cool pattern with one LED.
We had to make the BLINK function work without any delays. When this happened, it looked like the LED was always on. This is because the LED was turning on and off too fast for any human eye to see.
Our next task was to wire the breadboard with 4 LEDs.
Like the one with 1 LED, all of the lights are hooked up to a pin on the Arduino. The other side of the LED is hooked up to a resistor and the ground. We then had to make the LEDs light up in a cool pattern using the Blink program with the DELAY function. The DELAY function has to go through the amount of time given before it will move on to any other commands.
Our program had LEDs 2 and 4 turn on for 1 second. Then LED 2 turned off and LED 12 turned on for 1 second. Then LED 4 turned off and LED 8 turned on for 1 second. After that, LED 8 turned off. The pattern would then repeat itself over and over.
Each LED in our breadboard blinked at a different interval. We had LED 2 blink at 1 second on, 1 second off. LED 4 blinked at 2 seconds off, 2 seconds off. LED 8 blinked at half a second on, half a second off. LED 12 blinked at 1.5 seconds on, 1.5 seconds off.
That concluded our class on Tuesday. On Friday everyone showed their cool pattern in class and then Professor Banzaert showed us a new mechanism, a servo motor. The programs Sweep and Knob control the servo motor in different ways. Sweep makes the motor move back and forth 180 degrees in steps of 1 degree every 15 milliseconds.
We had to look at the program, understand it, and then change its behavior. We changed it so when the motor was going from 0 to 180 degrees, it would go in steps of 20 degrees every second. When the motor was going from 180 to 0 degrees, it would go in steps of 10 degrees every 150 milliseconds.
Knob controls the position of the servo motor with a potentiometer. The potentiometer had a knob on it that you could turn. Turning the knob 1023 degrees would turn the motor 180 degrees.
We had to look at the program, understand it, and then modify it so it could control the rate at which a LED turned on and off. We had to change from a servo to an LED. We made it so when the potentiometer was at 1023 degrees, the light would blink for 2 seconds on and then 2 seconds off. The rate at which it blinked got faster when the potentiometer went to 0 degrees
Summary
I found it was very important to understand the program before you try to change it. Breaking the program down line by line helps me to understand the syntax. I also found it was important to use the proper brackets or parenthesis. At first we couldn't get the blink without delay program to make 4 LEDs blink in a cool pattern. Later we found out that it was because we didn't put brackets around each of the terms
I liked the pattern for your four LEDs! The photos were large so it was easy to read the code too. I agree that it is definitely important to understand the code before trying to make several modifications.
ReplyDeleteYour pattern for the 4 LEDs was very interesting. I also liked your use of the different intervals in the BlinkWithoutDelay.
ReplyDeleteMy partner and I definitely also struggled with the brackets.
I really liked the straightforward format of this post. it made all of the information flow very easily and the videos were really helpful. I liked your LED blink pattern, very creative coding. You showed you understood the programs very well.
ReplyDelete