Created
October 9, 2020 14:14
-
-
Save EDISON-SCIENCE-CORNER/c213cea844616ca0ddbe65b01b9d2b3b 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
int f_button = 9; | |
int b_button = 8; | |
int l_button = 7; | |
int r_button = 6; | |
int m1=2; | |
int m2=3; | |
int m3=4; | |
int m4=5; | |
void setup () { | |
pinMode(f_button,INPUT_PULLUP); | |
pinMode(b_button,INPUT_PULLUP); | |
pinMode(l_button,INPUT_PULLUP); | |
pinMode(r_button,INPUT_PULLUP); | |
pinMode(m1,OUTPUT); | |
pinMode(m2,OUTPUT); | |
pinMode(m3,OUTPUT); | |
pinMode(m4,OUTPUT); | |
} | |
void loop() { | |
if ( digitalRead(f_button)==LOW) | |
{ | |
digitalWrite(m1, LOW); | |
digitalWrite(m3, LOW); | |
} | |
if ( digitalRead(b_button)==LOW) | |
{ | |
digitalWrite(m2,LOW ); | |
digitalWrite(m4,LOW); | |
} | |
if ( digitalRead(l_button)==LOW) | |
{ | |
digitalWrite(m1,LOW); | |
} | |
if ( digitalRead(r_button)==LOW) | |
{ | |
digitalWrite(m3,LOW); | |
} | |
else | |
{ | |
digitalWrite(m1,HIGH); | |
digitalWrite(m2,HIGH); | |
digitalWrite(m3,HIGH); | |
digitalWrite(m4,HIGH); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment