diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2006-03-11 04:35:36 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2006-03-11 04:35:36 +0000 |
commit | b89bc7df3a1de4452bd5ee1acad3a3129f1a920f (patch) | |
tree | a9653ea26096d708ad1d6caab9e8a5fdaf0faa78 /examples/Pd_Input | |
parent | 9be3af99fbc99fed49bbdccb634350d95d409098 (diff) |
got the firmware for the high-speed protocol sketched out, now I need to figure out the div/mod byte format
svn path=/trunk/externals/hardware/arduino/; revision=4691
Diffstat (limited to 'examples/Pd_Input')
-rw-r--r-- | examples/Pd_Input/Pd_Input.pde | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/examples/Pd_Input/Pd_Input.pde b/examples/Pd_Input/Pd_Input.pde index d5dd5e7..2099ffb 100644 --- a/examples/Pd_Input/Pd_Input.pde +++ b/examples/Pd_Input/Pd_Input.pde @@ -1,15 +1,18 @@ /* Pd_Input * ------------------ * - * This program reads all of the Analog inputs - * and sends the data to the computer as fast as - * possible. It was designed to work with the Pd - * patch of the same name in: - * Help -> Browser -> examples -> hardware + * This program reads all of the Analog and 12 Digital Inputs + * and sends the data to the computer as fast as possible. + * It reads one analog pin and two digital pins per cycle + * so that the time between reads on all pins remains + * constant. + * + * It was designed to work with the Pd patch of the same + * name in: Help -> Browser -> examples -> hardware * * (cleft) 2006 Hans-Christoph Steiner * @author: Hans-Christoph Steiner - * @date: 2006-03-04 + * @date: 2006-03-10 * @location: Polytechnic University, Brooklyn, New York, USA */ @@ -19,15 +22,43 @@ * without a delay() so its very fast. */ -int potPin = 0; +int analogPin = 0; +int digitalPin = 0; +int ledOut = 1; +int analogIn = 0; void setup() { - beginSerial(19200); + beginSerial(9600); } void loop() { - printByte(potPin + 65); // add 65 to get ASCII chars starting with A - printInteger(analogRead(potPin)); - potPin = potPin + 1; - if (potPin > 5) - potPin = 0; + /* + * get two digital ins + */ +/* + printByte(digitalRead(digitalPin)); + digitalPin = digitalPin + 1; + if (digitalPin > 11) + digitalPin = 0; + printByte(digitalRead(digitalPin)); + digitalPin = digitalPin + 1; + if (digitalPin > 11) + digitalPin = 0; +*/ + /* + * get analog in + */ + printByte(65); + analogIn = analogRead(analogPin); + printByte(analogIn / 127); + printByte(analogIn % 127); + analogPin = analogPin + 1; + if (analogPin > 5) + { + analogPin = 0; + // toggle the status LED (pin 13) + digitalWrite(13,ledOut); + ledOut = !ledOut; // alternate the LED + // the newline (ASCII 10) marks the start/end of the sequence + printNewline(); + } } |