Write the following Arduino program and please include the comments. thankyou Wr
ID: 3804022 • Letter: W
Question
Write the following Arduino program and please include the comments. thankyou
Write an Arduino sketch to simulate the traffic lights at 19^th and Boston. The lights should cycle green yellow red, with a shorter cycle time for Boston traffic and a longer cycle time for 19^th St There should be a short period when lights are red for both directions to avoid accidents. You could use realistic cycle-lengths, hut you'll get tired of waiting for a full day' s worth of cycles. So you might use a 5-second green and 1- second yellow for Boston and an 15-second green and 2-second yellow for 19^th St, with a 1 second period of red-both-ways. When a pedestrian is present, the green-light cycle length should be increased by 2 seconds for a pedestrian crossing Boston, and 4 seconds for a pedestrian crossing 19^th St When an emergency vehicle is detected, switch to solid red for both directions, until 2 seconds after the emergency vehicle is gone. From 10 PM to 7 AM, the lights should go to flashing red (Boston) and yellow (19^th St). Again, to avoid needing 24 hours to test your simulation, you may use 1 full cycle per hour for Red/Yellow/Green, and 2 flashes for Yellow/Red flashing. I don' t know what happens with the lights if a pedestrian presses the button between 10 PM & 7 AM...you can choose whether to give the pedestrian a green light, or just leave it blinking. Your program should use Serial.print(...) to print a log of what is happening on your computer screen. This will help the grader verify your program does what it should. The log should show what state the light is in, what the time delay is, and whether there are pedestrians waiting or an emergency vehicle coming.Explanation / Answer
#include <iostream.h>
#include <conio.h>
class workers
one : while(1)
cout<<" Choose your choice ";
cout<<"1) Create ";
cout<<"2) Display ";
cout<<"3) Jump to Main Menu ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case {1|one">one : for(count=0,i=0;i<10;i++)
getch();
break;
case three : goto start;
default: cout<<" Enter selection is invalid try again ";
}
}
case two : while(1)
cout<<" Choose your choice ";
cout<<"1) Create ";
cout<<"2) Display ";
cout<<"3) Jump to Main Menu ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case {1|one">one : for(count=0,i=0;i<10;i++)
getch();
break;
case three : goto start;
default: cout<<" Invalid choice try again ";
}
}
case three : while(1)
cout<<" Choose your choice ";
cout<<"1) Create ";
cout<<"2) Display ";
cout<<"3) Jump to Main Menu ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case {1|one">one : for(count=0,i=0;i<10;i++)
getch();
break;
case three : goto start;
default: cout<<" Invalid choice try again ";
}
}
case four : goto end;
}
}
end:
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.