aboutsummaryrefslogtreecommitdiff
path: root/examples/Pd_Input
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2006-03-14 22:31:39 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2006-03-14 22:31:39 +0000
commit36f0cb2366c18e2bde1d94c70ed7fb03dcb21e83 (patch)
tree7179708a3c5b653dee4daf43fdf615d59715f43d /examples/Pd_Input
parentb89bc7df3a1de4452bd5ee1acad3a3129f1a920f (diff)
got the basics of the byte-based speedy firmware working, now I got to get the Pd patch working with this firmware
svn path=/trunk/externals/hardware/arduino/; revision=4708
Diffstat (limited to 'examples/Pd_Input')
-rw-r--r--examples/Pd_Input/Pd_Input.pde41
1 files changed, 24 insertions, 17 deletions
diff --git a/examples/Pd_Input/Pd_Input.pde b/examples/Pd_Input/Pd_Input.pde
index 2099ffb..c2d574f 100644
--- a/examples/Pd_Input/Pd_Input.pde
+++ b/examples/Pd_Input/Pd_Input.pde
@@ -22,10 +22,13 @@
* without a delay() so its very fast.
*/
+int i;
int analogPin = 0;
int digitalPin = 0;
int ledOut = 1;
-int analogIn = 0;
+int analogData = 0;
+int digitalData = 0;
+int digitalOutputByte = 0;
void setup() {
beginSerial(9600);
}
@@ -33,24 +36,28 @@ void setup() {
void loop() {
/*
* 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;
-*/
+ */
+ digitalOutputByte = 0;
+ for(i=0;i<7;++i)
+ {
+ digitalData = digitalRead(i);
+ digitalOutputByte = digitalOutputByte + (2^(i+1)*digitalData);
+ }
+ printByte(digitalOutputByte);
+ digitalOutputByte = 0;
+ for(i=7;i<13;++i)
+ {
+ digitalData = digitalRead(i);
+ digitalOutputByte = digitalOutputByte + (2^(i-6)*digitalData);
+ }
+ printByte(digitalOutputByte);
/*
* get analog in
*/
- printByte(65);
- analogIn = analogRead(analogPin);
- printByte(analogIn / 127);
- printByte(analogIn % 127);
+ analogData = analogRead(analogPin);
+ // these two bytes get converted back into the whole number in Pd
+ printByte(analogData / 32); // div by 32 for the big byte
+ printByte(analogData % 32); // mod by 32 for the small byte
analogPin = analogPin + 1;
if (analogPin > 5)
{
@@ -59,6 +66,6 @@ void loop() {
digitalWrite(13,ledOut);
ledOut = !ledOut; // alternate the LED
// the newline (ASCII 10) marks the start/end of the sequence
- printNewline();
+ printByte(255);
}
}