Skip to content

Instantly share code, notes, and snippets.

@EDISON-SCIENCE-CORNER
Created October 9, 2020 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EDISON-SCIENCE-CORNER/c213cea844616ca0ddbe65b01b9d2b3b to your computer and use it in GitHub Desktop.
Save EDISON-SCIENCE-CORNER/c213cea844616ca0ddbe65b01b9d2b3b to your computer and use it in GitHub Desktop.
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