Skip to content

Instantly share code, notes, and snippets.

@johnschimmel
Created January 9, 2015 00:14
Show Gist options
  • Save johnschimmel/fb278d04634f1055aa5d to your computer and use it in GitHub Desktop.
Save johnschimmel/fb278d04634f1055aa5d to your computer and use it in GitHub Desktop.
fart knob
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int relay1 = 13; // pin 13
int relay2 = 12; // pin 12
int leftrightJoystick = A0;
int updownJoystick = A1;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
Serial.begin(9600);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
Serial.println(analogRead(leftrightJoystick));
// POINTING RIGHT - relay 1
if ( analogRead(leftrightJoystick) > 800 ) {
digitalWrite(relay1, HIGH); // turn the relay1 on
} else {
digitalWrite(relay1, LOW);
}
//POINTING LEFT - relay 2
if (analogRead(leftrightJoystick) < 200) {
digitalWrite(relay2, HIGH); // turn the relay1 on
} else {
digitalWrite(relay2, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment