Question

In: Computer Science

Write Arduino program to implement wiring three momentary switches to the Arduino board

Write Arduino program to implement wiring three momentary switches to the Arduino board

Solutions

Expert Solution

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!
===========================================================================

Related Solutions

Write an assembly program which will read the value of the switches on the board, parse...
Write an assembly program which will read the value of the switches on the board, parse this number by looking at the 4 least-significant bits, using the lookup table from the prelab to get the value necessary to display this hex number on a 7-segment display, using shift instructions to adjust registers as necessary to parse the next set of values. Repeat until all four displays are accounted for. Finally, when one register has a bit-stream necessary to display all...
Write a program to run on your Arduino and PortMaster board that will sequentially turn on...
Write a program to run on your Arduino and PortMaster board that will sequentially turn on and off the LED segments, so it resembles Cylon eyes (https://youtu.be/UajcgzK2shQ). Use the millis() construct shown in lecture rather than delay(). The traverse from one side to the other should take about 1 second.
Write a program that captures the transmission of a character from an Arduino board over serial...
Write a program that captures the transmission of a character from an Arduino board over serial communication (UART)
What would be the wiring setup and coding using an Arduino for a display of the...
What would be the wiring setup and coding using an Arduino for a display of the temperature of the room it is in?
Write the following in C language for Arduino: Write a program that turns on the LED...
Write the following in C language for Arduino: Write a program that turns on the LED at 25%, 50%, 75%, 100%, and then 0% brightness with a one second delay in between each change. Remember you are going to need to use a PWM pin and use the "analogWrite" command. The maximum value for our Arduino R3 boards is 255 and you need five steps (25%, 50%, 75%, 100%, and 0%) so you will need to determine the values for...
Write the following in C language for Arduino: Write a program that increases the LED brightness...
Write the following in C language for Arduino: Write a program that increases the LED brightness in five steps with each press of the button. Remember you are going to using a digital input and the "digitalRead" command. You are going to need to use a PWM pin and use the "analogWrite" command. The maximum value for our Arduino R3 boards is 255 and you need five steps (25%, 50%, 75%, 100%, and 0%) so you will need to determine...
Pharaphrase and rewrite the following paragraph: Arduino Arduino Uno is a microcontroller board b... pharaphrase and...
Pharaphrase and rewrite the following paragraph: Arduino Arduino Uno is a microcontroller board b... pharaphrase and rewrite the following paragraph: Arduino Arduino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connect it to...
Write a program in Arduino that, when it takes in a voltage range (0 to 5...
Write a program in Arduino that, when it takes in a voltage range (0 to 5 volts), gives a corresponding servo motor angle with a range from 0 to 180 degrees.
Produce program code to facilitate LED and switch interface with a microcontroller-based development board (Arduino). Explain...
Produce program code to facilitate LED and switch interface with a microcontroller-based development board (Arduino). Explain the programming process and interface circuits required
Using energia software Write a program for your MSP430 board to will perform the following three...
Using energia software Write a program for your MSP430 board to will perform the following three tasks: 1. Input: Take a character string as user input through the serial interface. 2. Processing: Convert the entire string to lower case, and 3. Output: Return the processed string to serial output, which will be displayed on your computer monitor. Example: If the input character string is, “Here I am”, the output should be, “here i am”. For serial input and output purpose,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT