From df5e499491efd1f3d05edf314723ef8e1cf4f3bc Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 12 Feb 2013 11:34:56 +0100 Subject: [PATCH] 4051 test sketch --- sketches/testing/_4051_test.ino | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sketches/testing/_4051_test.ino diff --git a/sketches/testing/_4051_test.ino b/sketches/testing/_4051_test.ino new file mode 100644 index 0000000..a64cb46 --- /dev/null +++ b/sketches/testing/_4051_test.ino @@ -0,0 +1,40 @@ +int potent = -1; +int tolerance = 4; + +const int s0 = 10; +const int s1 = 9; +const int s2 = 8; + +int pots[] = {-1,-1}; + +void setup() { + Serial.begin(9600); + pinMode(s0,OUTPUT); + pinMode(s1,OUTPUT); + pinMode(s2,OUTPUT); + +} + +void loop() { + digitalWrite(s0, LOW); + digitalWrite(s1, LOW); + digitalWrite(s1, LOW); + int read = analogRead(A1); + if (pots[0] < read - tolerance || pots[0] > read + tolerance) { + pots[0] = analogRead(A1); + Serial.print("pot 0: "); + Serial.print(pots[0]/8); + Serial.println(); + } + + digitalWrite(s0, HIGH); + digitalWrite(s1, LOW); + digitalWrite(s1, LOW); + read = analogRead(A1); + if (pots[1] < read - tolerance || pots[1] > read + tolerance) { + pots[1] = analogRead(A1); + Serial.print("pot 1: "); + Serial.print(pots[1]/8); + Serial.println(); + } +}