Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEED HELP WITH QUESTION 3: my code: //initialize delay between light changes int timer = 100; void setup() { //use a for loop to initialize

image text in transcribed
NEED HELP WITH QUESTION 3:
my code:
//initialize delay between light changes
int timer = 100;
void setup()
{
//use a for loop to initialize each pin as an output
for(int thisPin = 2; thisPin
{
pinMode(thisPin, OUTPUT);
Serial.begin(9600);
Serial.println(thisPin);
}
}
void loop()
{
//loop from the lowest pin to the highest
for(int thisPin = 2; thisPin
{
if(thisPin % 2 == 0) //If the pin is even
digitalWrite(thisPin, HIGH);
delay(timer); // Wait for 1000 millisecond(s)
digitalWrite(thisPin, LOW);
}
//loop from the highest pin to the lowest
for(int thisPin=7; thisPin>=2; thisPin--)
{
if(thisPin % 2 == 1) //If the pin is odd
//turn the pin on
digitalWrite(thisPin, HIGH);
delay(timer);
//turn the pin off
digitalWrite(thisPin, LOW);
}
}
1. Use serial communication to display which pin is lit in the serial monitor. (adjust the timer to change how fast the LED's change to 1 second) Initialize serial event using: Serial.begin(9600); Display in the serial monitor: Serial.println(thisPin); 2. Modify the code so that only the odd pins are lit on the way down, and only even pins are lit on the way up. 7 6 5 4 3 2 7 6 5 4 3 2 3. Modify the code so that the LED's turn on and off in an arbitrary order using an array. Initialize the array using: int ledPins () (2, 7, 4, 6, 5, 3); Turn on the LED's as follows: digitalWrito (ledPins(thispin), HIGH)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

Discuss at what point in time a theft loss generally is recognized?

Answered: 1 week ago

Question

implify the given expres te order of operations: 4. 7+2-3(2-:6)

Answered: 1 week ago