Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Formal Lab #1 Transmit the characters A through Z to the corn screen continuousl

ID: 2990462 • Letter: F

Question

Formal Lab #1 Transmit the characters A through Z to the corn screen continuously only if switch 1 and 2 are pressed. If you release one of the switches the program it will no longer transmit. If you press both switches again the program will resume where it left off. Switch 1 is on pin 11 and switch 2 is on pin 12 of the uC board. Place the program in a do while loop. If switch 0 is pressed stop the program entirely. Switch 0, 1 and 2 are acting as your sentinels and do effect how your program runs. Beep when switch 0 is pressed to alert you the program has come to an end. Use a do while loop. The beep command is tone(2, 2000, 500); Design the program using a nested if statement or you can use a logical operation. NOTE: Formal labs require flowcharts!

Explanation / Answer

char atoz='a' ; // char to be printed on screen
int s0,s1,s2;

void setup() {
pinMode(10,INPUT); // input mode for switch 0
pinMode(11,INPUT); // input mode for switch 1
pinMode(12,INPUT); // input mode for switch 2
Serial.begin(9600); // Turn the Serial Protocol ON
}

void loop() {
do{
s0=digitalRead(10);
//read switch 0
s1=digitalRead(11); //read switch 1
s2=digitalRead(12); //read switch 2
  
if ((s1=0) || (s2=0)) // if either s1 or s2 is pressed, then start the loop again
return; //return instruction starts the void loop from the beggining
// in arduino if you press the interfaced button, value read on the pin is 0.
//if the button is not pressed, then value read on the pin is 1
Serial.write(atoz); // print the character on screen through serial communication
atoz++; // if add 1 to cahr 'a', it becomes 'b'that is why this operation is done
if (atoz>'z' ) // if the printing is finished with printing 'z' then start again from 'a'
atoz='a';
}while (s0=1); // if s0 is not pressed then repeat the process
  
// if s0 is pressed, program comes out of the loop
tone(2,2000,500); // tone generation
exit(0); // exit the program
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote