First commit
This commit is contained in:
43
Peter D4/Peter D4.ino
Normal file
43
Peter D4/Peter D4.ino
Normal file
@ -0,0 +1,43 @@
|
||||
//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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user