Skip to content

Instantly share code, notes, and snippets.

@iamnbutler
Created November 19, 2015 23:47
Show Gist options
  • Save iamnbutler/20c15aeba030910f17dc to your computer and use it in GitHub Desktop.
Save iamnbutler/20c15aeba030910f17dc to your computer and use it in GitHub Desktop.
tempArduino1
// Vars
// LED Variables
const int rotateLED1 = 13,
rotateLED2 = 12,
rotateLED3 = 11,
rotateLED4 = 10,
startLED = 9;
// Button Variables
const int rotateBtn = 8,
resetBtn = 7,
leftBtn = 6,
rightBtn = 5,
downBtn = 4;
int rotateState = 0;
void setup() {
Serial.begin(9600);
// rotation LEDS
pinMode(rotateLED1, OUTPUT); // 0
pinMode(rotateLED2, OUTPUT); // 90
pinMode(rotateLED3, OUTPUT); // 180
pinMode(rotateLED4, OUTPUT); // 270
// start LED
pinMode(startLED, OUTPUT);
}
void loop() {
int rotateOut = digitalRead(rotateBtn);
if (rotateOut == HIGH) {
switch (rotateState) {
case 0:
Serial.println(0);
digitalWrite(rotateLED1, HIGH);
digitalWrite(rotateLED2, LOW);
digitalWrite(rotateLED3, LOW);
digitalWrite(rotateLED4, LOW);
rotateState = rotateState + 1;
break;
case 1:
Serial.println(90);
digitalWrite(rotateLED1, LOW);
digitalWrite(rotateLED2, HIGH);
digitalWrite(rotateLED3, LOW);
digitalWrite(rotateLED4, LOW);
rotateState++;
break;
case 2:
Serial.println(180);
digitalWrite(rotateLED1, LOW);
digitalWrite(rotateLED2, LOW);
digitalWrite(rotateLED3, HIGH);
digitalWrite(rotateLED4, LOW);
rotateState++;
break;
default:
Serial.println(270);
digitalWrite(rotateLED1, LOW);
digitalWrite(rotateLED2, LOW);
digitalWrite(rotateLED3, LOW);
digitalWrite(rotateLED4, HIGH);
rotateState = 0;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment