Problem 20 25 Points Write a program to simulate a caution l

Problem 2.0 (25 Points) Write a program to simulate a caution light with an LED connected to pin 9. Your program should not use the delay function. The caution light should blink every2seconds. (25 Points)

Solution

boolean t = true;
int i = 12;
void setup()
{
  pinMode(12,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(4,OUTPUT);
}


void loop()
{
  digitalWrite(i,HIGH);
  delay(50);
  digitalWrite(i,LOW);
  if(t == true)
  {
   i = i - 1;
  }
  else
  {
   i = i + 1;
}
if(i < 5)
{
i = 6;
t = false;
}
if(i > 12)
{
i = 11;
t = true;
}


}

 Problem 2.0 (25 Points) Write a program to simulate a caution light with an LED connected to pin 9. Your program should not use the delay function. The caution

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site