In: Computer Science
Write Arduino program to implement wiring three momentary switches to the Arduino board
Pseudo Code:
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
if (buttonState1 == HIGH) {
digitalWrite(ledPin1, HIGH);
}
if (buttonState2 == HIGH) {
digitalWrite(ledPin2, HIGH);
}
if (buttonState3 == HIGH) {
digitalWrite(ledPin3, HIGH);
}
else {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
}
}
Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions. Thank You! ===========================================================================