Commits

Johan Euphrosine committed e2b8b4a

add arduino driver for new keyboard

  • Participants
  • Parent commits 9d47603

Comments (0)

Files changed (3)

File arduino/keyboard.pde

+int pins[] = {2,3,4,5,6,7};
+int values[] = {0,0,0,0,0,0,0};
+
+void setup() {
+  Serial.begin(9600);
+  for (int i = 0; i < 6; i+=1) {
+    pinMode(pins[i], INPUT);           // set pin to input
+    digitalWrite(pins[i], HIGH);       // turn on pullup resistors
+  }
+}
+
+void loop() {
+  char steps[] = {'.','.','.','.','.','.',0};
+  boolean changed = false;
+    for (int i = 0; i < 6; i+=1) {
+      int value = digitalRead(pins[i]);
+      if (value != values[i]) {
+          changed = true;
+          values[i] = value;
+      }
+      steps[i] = value == LOW ? 'o' : '.';
+    }
+   if (changed) {
+      Serial.println(steps);
+   }
+}

File arduino/touchpad.pde

+/*
+  Analog Input
+ Demonstrates analog input by reading an analog sensor on analog pin 0 and
+ turning on and off a light emitting diode(LED)  connected to digital pin 13. 
+ The amount of time the LED will be on and off depends on
+ the value obtained by analogRead(). 
+ 
+ The circuit:
+ * Potentiometer attached to analog input 0
+ * center pin of the potentiometer to the analog pin
+ * one side pin (either one) to ground
+ * the other side pin to +5V
+ * LED anode (long leg) attached to digital output 13
+ * LED cathode (short leg) attached to ground
+ 
+ * Note: because most Arduinos have a built-in LED attached 
+ to pin 13 on the board, the LED is optional.
+ 
+ 
+ Created by David Cuartielles
+ Modified 16 Jun 2009
+ By Tom Igoe
+ Modified 12 August 2009 By Johan Euphrosine for waltz-apple need
+ 
+ http://arduino.cc/en/Tutorial/AnalogInput
+ 
+ */
+
+int sensorPin = 0;    // select the input pin for the potentiometer
+int ledPin = 6;      // select the pin for the LED
+int sensorValue = 0;  // variable to store the value coming from the sensor
+int leds[] = {10, 11, 13, 6, 7, 9};
+int sensors[] = {3, 4, 5, 2, 1, 0};
+int values[] = {0, 0, 0, 0, 0, 0};
+  
+void setup() {
+  // declare the ledPin as an OUTPUT:
+  Serial.begin(9600);      // open the serial port at 9600 bps:
+  for (int i = 0; i < 6; i+=1) {
+      pinMode(leds[i], OUTPUT);       
+  }
+}
+
+void loop() {
+  char steps[] = {'.','.','.','.','.','.',0};  
+  boolean changed = false;
+    for (int i = 0; i < 6; i+=1) {
+      int value = analogRead(sensors[i]);
+      // turn the ledPin on
+      if (value > 0) {
+        digitalWrite(leds[i], HIGH);
+      } else {
+        digitalWrite(leds[i], LOW);
+      }
+      if ((value > 0) != (values[i] > 0)) {
+          changed = true;
+          values[i] = value;
+      }
+      steps[i] = value > 0 ? 'o' : '.';
+    }
+   if (changed) {
+      Serial.println(steps);
+   }
+}

File waltzapple.pde

-/*
-  Analog Input
- Demonstrates analog input by reading an analog sensor on analog pin 0 and
- turning on and off a light emitting diode(LED)  connected to digital pin 13. 
- The amount of time the LED will be on and off depends on
- the value obtained by analogRead(). 
- 
- The circuit:
- * Potentiometer attached to analog input 0
- * center pin of the potentiometer to the analog pin
- * one side pin (either one) to ground
- * the other side pin to +5V
- * LED anode (long leg) attached to digital output 13
- * LED cathode (short leg) attached to ground
- 
- * Note: because most Arduinos have a built-in LED attached 
- to pin 13 on the board, the LED is optional.
- 
- 
- Created by David Cuartielles
- Modified 16 Jun 2009
- By Tom Igoe
- Modified 12 August 2009 By Johan Euphrosine for waltz-apple need
- 
- http://arduino.cc/en/Tutorial/AnalogInput
- 
- */
-
-int sensorPin = 0;    // select the input pin for the potentiometer
-int ledPin = 6;      // select the pin for the LED
-int sensorValue = 0;  // variable to store the value coming from the sensor
-int leds[] = {10, 11, 13, 6, 7, 9};
-int sensors[] = {3, 4, 5, 2, 1, 0};
-int values[] = {0, 0, 0, 0, 0, 0};
-  
-void setup() {
-  // declare the ledPin as an OUTPUT:
-  Serial.begin(9600);      // open the serial port at 9600 bps:
-  for (int i = 0; i < 6; i+=1) {
-      pinMode(leds[i], OUTPUT);       
-  }
-}
-
-void loop() {
-  char steps[] = {'.','.','.','.','.','.',0};  
-  boolean changed = false;
-    for (int i = 0; i < 6; i+=1) {
-      int value = analogRead(sensors[i]);
-      // turn the ledPin on
-      if (value > 0) {
-        digitalWrite(leds[i], HIGH);
-      } else {
-        digitalWrite(leds[i], LOW);
-      }
-      if ((value > 0) != (values[i] > 0)) {
-          changed = true;
-          values[i] = value;
-      }
-      steps[i] = value > 0 ? 'o' : '.';
-    }
-   if (changed) {
-      Serial.println(steps);
-   }
-}