My homework for ‘Creating w/Code’ was to make a functioning prototype of some type of creation using an Arduino and writing reiterative sketches starting with one LED leading up to 3 LEDs and a Serial Bus:
Q1 What does your Code Look Like to control 1 LED?
I changed the delay to have the LED blink faster:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a half second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a quarter second
}
Q2 What does your Code Look Like to control 2 LEDs?
I alternated the two LEDs to blink opposite of each other at separate delays:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 and 10 as outputs.
pinMode(13, OUTPUT);
pinMode(10, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a half a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a quarter second
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a quarter second
digitalWrite(10, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a half second
}
Q3 What does your Code Look Like to control 3 LEDs?
I added a third LED and made a serial bus for the circuit:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 and 10 as outputs.
pinMode(13, OUTPUT);
pinMode(10, OUTPUT);
pinMode(7, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a half a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a quarter second
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a quarter second
digitalWrite(10, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a half second
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
delay(333); // wait for a third of a second
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(333); // wait for a third of a second
}
And here it is:
And to make it functional – A Trippy Lamp:
This project was good because I could add on to the work that I did before and the reiteration helped me to retain the concepts learned along the way. In my previous post I wrote about how I understood MOST of what I was doing, but felt a little more disequilibrium than I would have preferred. Here I was able to put it all together without feeling out of my range. I love the hook of having a product for the prototype – to have a purpose for it. I was in no mood to create flowers (another project suggestion), nor did I have the materials at hand, but I do like my lamp!
I love the lamp. Garden theme was just an entry point. Glad you found an entry point that worked for you!