Created
April 3, 2017 04:05
-
-
Save angelaperrone/e6c95607c7d0830f3294060445051505 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
//Code created by Angela Perrone | |
//Arduino Example Sketches used for reference (simple, striptest, buttoncycler) | |
//Book - Resistor Ladder | |
//Tom Igoe Switch State Code | |
//Gustavo E de Campos Abbott | |
const int pin1 = A0; | |
int lastRotary = 0; | |
//int currentRotary = 13; | |
int cases; | |
void setup() { | |
Serial.begin (9600); | |
pinMode(pin1, INPUT_PULLUP); | |
} | |
void loop() { | |
//Serial.print("Current Rotary "); | |
//Serial.println(currentRotary); | |
//Serial.print("Last Rotary "); | |
//Serial.println(lastRotary); | |
int rotary = analogRead(pin1); | |
// Serial.print("Rotary Value"); | |
// Serial.println(rotary); | |
// if (rotary != (lastRotary - 5) && rotary != (lastRotary - 4)&&rotary != lastRotary && rotary != (lastRotary - 3) && rotary != (lastRotary - 2) && rotary != (lastRotary - 1) && rotary != (lastRotary + 5)&&rotary != (lastRotary + 4)&&rotary != (lastRotary + 3) && rotary != (lastRotary + 2) && rotary != (lastRotary + 1)) { | |
// if (rotary != constrain(lastRotary, lastRotary - 5, lastRotary + 5)) { | |
// if (rotary != lastRotary) { | |
//CHANNEL 1 | |
if (rotary >= 0 && rotary <= 49 && cases != 1) { | |
Serial.println(1); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 1; | |
} | |
//CHANNEL 2 | |
if (rotary == 1023 && cases != 2) { | |
Serial.println(2); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 2; | |
} | |
//CHANNEL 3 | |
if (rotary < 1000 && rotary >= 900 && cases != 3) { | |
Serial.println(3); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 3; | |
} | |
//CHANNEL 4 | |
if (rotary >= 820 && rotary <= 880 && cases != 4) { | |
Serial.println(4); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 4; | |
} | |
//CHANNEL 5 | |
if (rotary >= 720 && rotary <= 780 && cases != 5) { | |
Serial.println(5); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 5; | |
} | |
//CHANNEL 6 | |
if (rotary >= 620 && rotary <= 690 && cases != 6) { | |
Serial.println(6); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 6; | |
} | |
//CHANNEL 7 | |
if (rotary >= 520 && rotary <= 580 && cases != 7) { | |
Serial.println(7); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 7; | |
} | |
//CHANNEL 8 | |
if (rotary >= 430 && rotary <= 490 && cases != 8) { | |
Serial.println(8); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 8; | |
} | |
//CHANNEL 9 | |
if (rotary >= 330 && rotary <= 399 && cases != 9) { | |
Serial.println(9); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 9; | |
} | |
//CHANNEL 10 | |
if (rotary >= 230 && rotary <= 299 && cases != 10) { | |
Serial.println(10); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 10; | |
} | |
//CHANNEL 11 | |
if (rotary >= 150 && rotary <= 220 && cases != 11) { | |
Serial.println(11); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 11; | |
} | |
//CHANNEL 12 | |
if (rotary >= 50 && rotary <= 120 && cases != 12) { | |
Serial.println(12); | |
Serial.print("Rotary Value"); | |
Serial.println(rotary); | |
cases = 12; | |
} | |
//lastRotary = rotary; | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment