lostInSpace/Peter D4/Peter D4.ino
2023-02-14 21:16:47 +00:00

44 lines
847 B
C++

//LED pins
int peter1 = 10;
int peter2 = 11;
int peter3 = 12;
//Switch Pins
int switchyone = 2; //Red LED
int switchytwo = 3; //Green LED
int switchythree = 4; // Blue LED
void setup() {
// setting up input and output
pinMode(peter1,OUTPUT);
pinMode(peter2,OUTPUT);
pinMode(peter3,OUTPUT);
pinMode(switchyone,INPUT);
pinMode(switchytwo,INPUT);
pinMode(switchythree,INPUT);
}
//Now for the code
void loop() {
if (digitalRead(switchyone) == HIGH){ // Check switch one
digitalWrite(peter1,HIGH);
}
else {
digitalWrite(peter1,LOW);
}
if (digitalRead(switchytwo) == HIGH){ // Check switch two
digitalWrite(peter2,HIGH);
}
else {
digitalWrite(peter2,LOW);
}
if (digitalRead(switchythree) == HIGH){ //Check switch three
digitalWrite(peter3,HIGH);
}
else {
digitalWrite(peter3,LOW);
}
}