Created
September 6, 2018 21:21
-
-
Save aidancbrady/5a56e3c61c9e73e90c26dc8545f4a0b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int buttonPin1 = 2; // the number of the pushbutton pin | |
const int ledPin1 = 8; // the number of the LED pin | |
const int buttonPin2 = 3; | |
const int ledPin2 = 9; | |
const int buttonPin3 = 4; | |
const int ledPin3 = 10; | |
const int ButtonPinMaster = 5; | |
// variables will change: | |
int buttonState1 = 0; // variable for reading the pushbutton status | |
int buttonState2 = 0; | |
int buttonState3 = 0; | |
int buttonStateMaster = 0; | |
void setup() { | |
Serial.begin(9600); | |
// initialize the LED pin as an output: | |
pinMode(ledPin1, OUTPUT); | |
pinMode(ledPin2, OUTPUT); | |
pinMode(ledPin3, OUTPUT); | |
// initialize the pushbutton pin as an input: | |
pinMode(buttonPin1, INPUT); | |
pinMode(buttonPin2, INPUT); | |
pinMode(buttonPin3, INPUT); | |
pinMode(ButtonPinMaster, INPUT); | |
} | |
void loop() { | |
// read the state of the pushbutton value: | |
buttonState1 = digitalRead(buttonPin1); | |
buttonState2 = digitalRead(buttonPin2); | |
buttonState3 = digitalRead(buttonPin3); | |
buttonStateMaster = digitalRead(ButtonPinMaster); | |
Serial.println(buttonState1); | |
// check if the pushbutton is pressed. If it is, the buttonState is HIGH: | |
if(buttonStateMaster == HIGH) { | |
digitalWrite(ledPin1, HIGH); | |
digitalWrite(ledPin2, HIGH); | |
digitalWrite(ledPin3, HIGH); | |
} else { | |
digitalWrite(ledPin1, buttonState1); | |
digitalWrite(ledPin2, buttonState2); | |
digitalWrite(ledPin3, buttonState3); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment