To Do Part 1 Set up the circuit shown in the LED (Links to an external site.)Lin
ID: 2085746 • Letter: T
Question
To Do
Part 1
Set up the circuit shown in the LED (Links to an external site.)Links to an external site..
Note: The JDH kits do not have 270-ohm resistor. Use the next higher value.
Load the "Blink" Sketch, compile and run it.
Change the LED from pin 13 to pin 7, change the sketch, compile and run the sketch.
Show your work to your instructor.
Part 2
Using for loops make the LED blink on and off 5 times for one second, and then 5 times for 0.5 second.
Save a copy of this sketch so that you can submit it.
Part 3
Modify the circuit by adding three more LEDS and resistors. Connect them to pins 8, 9, and 10.
Modify your sketch so that it turns on a LED for one second, then turns on a second LED for one second, and so on until all of the LEDs are on. Leave all four LEDs on for one second. Then turn the LEDs off, in the same order, waiting one second between each. Leave all of the LEDs off for one second. The repeat the cycle.
Save a copy of this sketch so that you can submit it.
Part 4
Modify the sketch so the one LED is on for one second, turns off, and the next LED turns on
Save a copy of this sketch so that you can submit it.
Part 5
Make a sketch that lights up the leds in any pattern you wish.
This is the link: https://learn.adafruit.com/adafruit-arduino-lesson-2-leds/blinking-the-led
copy and paste it into a new window.
Explanation / Answer
Part 1: I am writing code that you can use for these assignments
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 7;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Part 2:
/*
Blink
Turns on and off an LED 5 times for one second, then on and off for 0.5 second, 5 times.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 7;
int i;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
for(i=1; i<=5; i++)
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
for(i=1; i<=5; i++)
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
}
Part 3:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led1 = 7;
int led2 = 8;
int led3 = 9;
int led4 = 10;
int i;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led2, HIGH);
delay(1000);
digitalWrite(led3, HIGH);
delay(1000);
digitalWrite(led4, HIGH);
delay(1000);
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(led2, LOW);
delay(1000);
digitalWrite(led3, LOW);
delay(1000);
digitalWrite(led4, LOW);
delay(1000);
}
Part 4:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led1 = 7;
int led2 = 8;
int led3 = 9;
int led4 = 10;
int i;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(led2, HIGH);
delay(1000);
digitalWrite(led2, LOW);
delay(1000);
digitalWrite(led3, HIGH);
delay(1000);
digitalWrite(led3, LOW);
delay(1000);
digitalWrite(led4, HIGH);
delay(1000);
digitalWrite(led4, LOW);
delay(1000);
}
Thanks and Regards
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.