aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Pd_firmware/Pd_firmware.pde67
-rw-r--r--arduino-test.pd474
-rw-r--r--arduino.pd66
3 files changed, 319 insertions, 288 deletions
diff --git a/Pd_firmware/Pd_firmware.pde b/Pd_firmware/Pd_firmware.pde
index ca8c79a..e678917 100644
--- a/Pd_firmware/Pd_firmware.pde
+++ b/Pd_firmware/Pd_firmware.pde
@@ -51,7 +51,7 @@
* TODO: use Program Control to load stored profiles from EEPROM
*/
-/* cvs version: $Id: Pd_firmware.pde,v 1.27 2007-03-05 17:08:51 eighthave Exp $ */
+/* cvs version: $Id: Pd_firmware.pde,v 1.28 2007-03-06 06:59:43 eighthave Exp $ */
/*==============================================================================
* MESSAGE FORMATS
@@ -183,6 +183,11 @@
// for comparing along with INPUT and OUTPUT
#define PWM 2
+// for selecting digital inputs
+#define PB 2 // digital input, pins 8-13
+#define PC 3 // analog input port
+#define PD 4 // digital input, pins 0-7
+
#define MAX_DATA_BYTES 2 // max number of data bytes in non-SysEx messages
/* message command bytes */
#define DIGITAL_MESSAGE 0x90 // send data for a digital pin
@@ -203,16 +208,14 @@
/* input message handling */
byte waitForData = 0; // this flag says the next serial input will be data
-byte executeMultiByteCommand = 0; // command to execute after getting multi-byte data
+byte executeMultiByteCommand = 0; // execute this after getting multi-byte data
byte multiByteChannel = 0; // channel data for multiByteCommands
byte storedInputData[MAX_DATA_BYTES] = {0,0}; // multi-byte data
/* digital pins */
boolean digitalInputsEnabled = false; // output digital inputs or not
-byte digitalInputHighByte = 0;
-byte digitalInputLowByte = 0;
-byte previousDigitalInputHighByte = 0; // previous output to test for change
-byte previousDigitalInputLowByte = 0; // previous output to test for change
-int digitalPinStatus = 0; // bitwise array to store pin status 0=INPUT,1=OUTPUT
+int digitalInputs;
+int previousDigitalInputs; // previous output to test for change
+int digitalPinStatus = 3; // bitwise array to store pin status, ignore RxTx pins
/* PWM/analog outputs */
int pwmStatus = 0; // bitwise array to store PWM status
/* analog inputs */
@@ -243,7 +246,7 @@ void outputDigitalBytes(byte pin0_6, byte pin7_13) {
// this should be converted to use PORTs
twoBytesForPorts = pin0_6 + (pin7_13 << 7);
- for(i=0; i<14; ++i) {
+ for(i=2; i<TOTAL_DIGITAL_PINS; ++i) { // ignore Rx,Tx pins (0 and 1)
mask = 1 << i;
if( (digitalPinStatus & mask) && !(pwmStatus & mask) ) {
digitalWrite(i, twoBytesForPorts & mask);
@@ -256,7 +259,16 @@ void outputDigitalBytes(byte pin0_6, byte pin7_13) {
* to the Serial output queue using Serial.print() */
void checkDigitalInputs(void) {
if(digitalInputsEnabled) {
- // this should use _SFR_IO8()
+ previousDigitalInputs = digitalInputs;
+ digitalInputs = _SFR_IO8(port_to_input[PB]) << 8; // get pins 8-13
+ digitalInputs += _SFR_IO8(port_to_input[PD]); // get pins 0-7
+ digitalInputs = digitalInputs &~ digitalPinStatus; // ignore pins set OUTPUT
+ if(digitalInputs != previousDigitalInputs) {
+ // TODO: implement more ports as channels for more than 16 digital pins
+ Serial.print(DIGITAL_MESSAGE,BYTE);
+ Serial.print(digitalInputs % 128, BYTE); // Tx pins 0-6
+ Serial.print(digitalInputs >> 7, BYTE); // Tx pins 7-13
+ }
}
}
@@ -265,23 +277,25 @@ void checkDigitalInputs(void) {
* two bit-arrays that track Digital I/O and PWM status
*/
void setPinMode(byte pin, byte mode) {
- if(mode == INPUT) {
- digitalPinStatus = digitalPinStatus &~ (1 << pin);
- pwmStatus = pwmStatus &~ (1 << pin);
- digitalWrite(pin,LOW); // turn off pin before switching to INPUT
- pinMode(pin,INPUT);
- }
- else if(mode == OUTPUT) {
- digitalPinStatus = digitalPinStatus | (1 << pin);
- pwmStatus = pwmStatus &~ (1 << pin);
- pinMode(pin,OUTPUT);
- }
- else if( mode == PWM ) {
- digitalPinStatus = digitalPinStatus | (1 << pin);
- pwmStatus = pwmStatus | (1 << pin);
- pinMode(pin,OUTPUT);
- }
+ if(pin > 1) { // ignore RxTx pins (0,1)
+ if(mode == INPUT) {
+ digitalPinStatus = digitalPinStatus &~ (1 << pin);
+ pwmStatus = pwmStatus &~ (1 << pin);
+ digitalWrite(pin,LOW); // turn off pin before switching to INPUT
+ pinMode(pin,INPUT);
+ }
+ else if(mode == OUTPUT) {
+ digitalPinStatus = digitalPinStatus | (1 << pin);
+ pwmStatus = pwmStatus &~ (1 << pin);
+ pinMode(pin,OUTPUT);
+ }
+ else if( mode == PWM ) {
+ digitalPinStatus = digitalPinStatus | (1 << pin);
+ pwmStatus = pwmStatus | (1 << pin);
+ pinMode(pin,OUTPUT);
+ }
// TODO: save status to EEPROM here, if changed
+ }
}
// -----------------------------------------------------------------------------
@@ -424,12 +438,11 @@ void setup() {
* LOOP()
*============================================================================*/
void loop() {
- ///analogWrite(11, tmp);++tmp;delay(2);
/* DIGITALREAD - as fast as possible, check for changes and output them to the
* FTDI buffer using Serial.print() */
checkDigitalInputs();
if(timer0_overflow_count > nextExecuteTime) {
- nextExecuteTime = timer0_overflow_count + 4; // run this every 4ms
+ nextExecuteTime = timer0_overflow_count + 19; // run this every 20ms
/* SERIALREAD - Serial.read() uses a 128 byte circular buffer, so handle
* all serialReads at once, i.e. empty the buffer */
checkForSerialReceive();
diff --git a/arduino-test.pd b/arduino-test.pd
index e8638c9..acb607d 100644
--- a/arduino-test.pd
+++ b/arduino-test.pd
@@ -1,4 +1,4 @@
-#N canvas 206 22 667 540 10;
+#N canvas 60 22 669 538 10;
#X obj 512 7 import hardware mapping;
#X obj 323 136 cnv 15 100 22 empty empty empty 20 12 0 14 -253938 -66577
0;
@@ -44,14 +44,14 @@
;
#X obj 98 119 hsl 150 17 0 1 0 0 empty empty PWM_control_(0-1) -2 -6
1 10 -225271 -1 -1 0 0;
-#X obj 277 332 tgl 15 1 empty empty empty 0 -6 0 8 -225271 -1 -1 0
+#X obj 277 332 tgl 15 1 empty empty empty 0 -6 0 8 -225271 -1 -1 1
1;
#X text 454 156 how many analogIns to enable:;
-#X obj 455 217 tgl 15 1 empty empty empty 0 -6 0 8 -257472 -1 -1 0
+#X obj 455 217 tgl 15 1 empty empty empty 0 -6 0 8 -257472 -1 -1 1
1;
#X text 478 216 enable/disable digitalIns;
#X msg 455 235 digitalIns \$1;
-#X msg 455 193 analogIns 1 0;
+#X msg 455 193 analogIns 0 0;
#N canvas 162 133 610 460 serin 0;
#X obj 59 337 outlet;
#X obj 59 266 trigger bang anything;
@@ -105,7 +105,7 @@
#X connect 20 0 0 0;
#X coords 0 -1 1 1 120 16 1 60 60;
#X restore 455 173 pd serin;
-#N canvas 77 268 486 336 debugging 0;
+#N canvas 77 268 490 340 debugging 0;
#X obj 136 31 inlet;
#X obj 324 29 inlet;
#X obj 27 31 inlet;
@@ -168,7 +168,7 @@
#X text 300 311 <- argument sets port #;
#X msg 62 119 off;
#X obj 40 91 hradio 15 1 0 14 empty empty empty 0 -6 0 8 -176124 -1
--1 9;
+-1 10;
#X text 148 77 7;
#X text 42 77 0;
#X text 189 77 10;
@@ -224,143 +224,78 @@
#X connect 16 0 17 0;
#X connect 17 0 14 0;
#X restore 41 145 pd pwm;
-#X msg 41 167 pwm 9 0;
+#X msg 41 167 pwm 10 0;
#X msg 328 195 info;
#X msg 367 195 version;
#X obj 230 332 spigot;
#X text 13 6 The [arduino] object works with the Firmata firmware for
Arduino (previously known as Pduino firmware).;
-#X obj 347 97 tgl 15 0 empty empty 1 3 -6 1 12 -260818 -1 -1 0 1;
-#X obj 365 97 tgl 15 0 empty empty 2 3 -6 1 12 -260818 -1 -1 0 1;
-#X obj 383 97 tgl 15 0 empty empty 3 3 -6 1 12 -260818 -1 -1 0 1;
-#X obj 401 97 tgl 15 0 empty empty 4 3 -6 1 12 -260818 -1 -1 0 1;
-#X obj 419 97 tgl 15 0 empty empty 5 3 -6 1 12 -260818 -1 -1 0 1;
-#X obj 437 97 tgl 15 0 empty empty 6 3 -6 1 12 -260818 -1 -1 0 1;
-#X obj 455 97 tgl 15 0 empty empty 7 3 -6 1 12 -260818 -1 -1 0 1;
-#X obj 473 97 tgl 15 0 empty empty 8 3 -6 1 12 -260818 -1 -1 0 1;
-#X obj 491 97 tgl 15 0 empty empty 9 3 -6 1 12 -260818 -1 -1 0 1;
-#X obj 509 97 tgl 15 0 empty empty 10 0 -6 1 12 -260818 -1 -1 0 1;
-#X obj 527 97 tgl 15 0 empty empty 11 0 -6 1 12 -260818 -1 -1 0 1;
-#X obj 545 97 tgl 15 0 empty empty 12 0 -6 1 12 -260818 -1 -1 0 1;
-#X obj 563 97 tgl 15 0 empty empty 13 0 -6 1 12 -260818 -1 -1 0 1;
-#X obj 329 97 tgl 15 0 empty empty 0 3 -6 1 12 -260818 -1 -1 0 1;
-#N canvas 518 328 766 316 send-to-arduino---------------- 0;
-#X obj 49 24 inlet;
-#X obj 89 24 inlet;
-#X obj 128 24 inlet;
-#X obj 168 24 inlet;
-#X obj 208 24 inlet;
-#X obj 248 24 inlet;
-#X obj 287 24 inlet;
-#X obj 327 24 inlet;
-#X obj 368 23 inlet;
-#X obj 408 23 inlet;
-#X obj 447 23 inlet;
-#X obj 487 23 inlet;
-#X obj 527 23 inlet;
-#X msg 49 66 pinMode 0 \$1;
-#X msg 89 88 pinMode 1 \$1;
-#X msg 128 110 pinMode 2 \$1;
-#X msg 168 130 pinMode 3 \$1;
-#X msg 208 62 pinMode 4 \$1;
-#X msg 248 84 pinMode 5 \$1;
-#X msg 287 106 pinMode 6 \$1;
-#X msg 327 126 pinMode 7 \$1;
-#X msg 368 58 pinMode 8 \$1;
-#X msg 408 80 pinMode 9 \$1;
-#X msg 447 102 pinMode 10 \$1;
-#X msg 487 122 pinMode 11 \$1;
-#X msg 527 50 pinMode 12 \$1;
-#X obj 566 23 inlet;
-#X msg 566 70 pinMode 13 \$1;
-#X obj 305 196 prepend set;
-#X obj 305 254 outlet;
-#X obj 305 215 trigger bang anything;
-#X connect 0 0 13 0;
-#X connect 1 0 14 0;
-#X connect 2 0 15 0;
-#X connect 3 0 16 0;
-#X connect 4 0 17 0;
-#X connect 5 0 18 0;
-#X connect 6 0 19 0;
-#X connect 7 0 20 0;
-#X connect 8 0 21 0;
-#X connect 9 0 22 0;
-#X connect 10 0 23 0;
-#X connect 11 0 24 0;
-#X connect 12 0 25 0;
-#X connect 13 0 28 0;
-#X connect 14 0 28 0;
-#X connect 15 0 28 0;
-#X connect 16 0 28 0;
-#X connect 17 0 28 0;
-#X connect 18 0 28 0;
-#X connect 19 0 28 0;
-#X connect 20 0 28 0;
-#X connect 21 0 28 0;
-#X connect 22 0 28 0;
-#X connect 23 0 28 0;
-#X connect 24 0 28 0;
-#X connect 25 0 28 0;
-#X connect 26 0 27 0;
-#X connect 27 0 28 0;
-#X connect 28 0 30 0;
-#X connect 30 0 29 0;
-#X connect 30 1 29 0;
-#X restore 329 116 pd send-to-arduino----------------;
+#X obj 363 97 tgl 15 0 empty empty 2 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 380 97 tgl 15 0 empty empty 3 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 397 97 tgl 15 0 empty empty 4 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 414 97 tgl 15 0 empty empty 5 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 431 97 tgl 15 0 empty empty 6 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 448 97 tgl 15 0 empty empty 7 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 465 97 tgl 15 0 empty empty 8 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 482 97 tgl 15 0 empty empty 9 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 499 97 tgl 15 0 empty empty 10 0 -6 1 12 -260818 -1 -1 0 1;
+#X obj 516 97 tgl 15 0 empty empty 11 0 -6 1 12 -260818 -1 -1 0 1;
+#X obj 533 97 tgl 15 0 empty empty 12 0 -6 1 12 -260818 -1 -1 0 1;
+#X obj 550 97 tgl 15 0 empty empty 13 0 -6 1 12 -260818 -1 -1 0 1;
#X text 328 64 turn on output mode for each pin (off=input);
-#X msg 329 138 pinMode 12 0;
-#N canvas 101 54 463 340 sending 0;
+#X msg 329 138 pinMode 10 0;
+#N canvas 101 54 471 348 sending 0;
#X obj 69 158 cnv 15 100 22 empty empty empty 20 12 0 14 -253938 -66577
0;
#X obj 78 244 outlet;
-#X msg 78 161 digital 0 1;
-#X obj 197 98 tgl 15 0 empty empty 7 4 -6 1 12 -233017 -1 -1 1 1;
-#X obj 214 98 tgl 15 0 empty empty 8 4 -6 1 12 -233017 -1 -1 1 1;
-#X obj 231 98 tgl 15 0 empty empty 9 4 -6 1 12 -233017 -1 -1 1 1;
-#X obj 248 98 tgl 15 0 empty empty 10 0 -6 1 12 -233017 -1 -1 1 1;
-#X obj 265 98 tgl 15 0 empty empty 11 0 -6 1 12 -233017 -1 -1 1 1;
-#X obj 282 98 tgl 15 0 empty empty 12 0 -6 1 12 -233017 -1 -1 1 1;
-#X obj 299 98 tgl 15 0 empty empty 13 0 -6 1 12 -233017 -1 -1 1 1;
-#X obj 78 98 tgl 15 0 empty empty 0 4 -6 1 12 -233017 -1 -1 1 1;
-#X obj 95 98 tgl 15 0 empty empty 1 4 -6 1 12 -233017 -1 -1 1 1;
-#X obj 112 98 tgl 15 0 empty empty 2 4 -6 1 12 -233017 -1 -1 1 1;
-#X obj 129 98 tgl 15 0 empty empty 3 4 -6 1 12 -233017 -1 -1 1 1;
-#X obj 146 98 tgl 15 0 empty empty 5 4 -6 1 12 -233017 -1 -1 1 1;
-#X obj 163 98 tgl 15 0 empty empty 6 4 -6 1 12 -233017 -1 -1 1 1;
-#X obj 180 98 tgl 15 0 empty empty 7 4 -6 1 12 -233017 -1 -1 1 1;
-#N canvas 482 328 802 352 generate 0;
-#X obj 49 24 inlet;
-#X obj 89 24 inlet;
-#X obj 128 24 inlet;
-#X obj 168 24 inlet;
-#X obj 208 24 inlet;
-#X obj 248 24 inlet;
-#X obj 287 24 inlet;
-#X obj 327 24 inlet;
-#X obj 368 23 inlet;
-#X obj 408 23 inlet;
-#X obj 447 23 inlet;
-#X obj 487 23 inlet;
-#X obj 527 23 inlet;
-#X msg 49 66 digital 0 \$1;
-#X msg 89 88 digital 1 \$1;
-#X msg 128 110 digital 2 \$1;
-#X msg 168 130 digital 3 \$1;
-#X msg 208 62 digital 4 \$1;
-#X msg 248 84 digital 5 \$1;
-#X msg 287 106 digital 6 \$1;
-#X msg 327 126 digital 7 \$1;
-#X msg 368 58 digital 8 \$1;
-#X msg 408 80 digital 9 \$1;
-#X msg 447 102 digital 10 \$1;
-#X msg 487 122 digital 11 \$1;
-#X msg 527 50 digital 12 \$1;
-#X obj 566 23 inlet;
-#X msg 566 70 digital 13 \$1;
-#X obj 305 196 prepend set;
-#X obj 305 254 outlet;
-#X obj 305 215 trigger bang anything;
+#X msg 78 161 digital 0 0;
+#X obj 197 98 tgl 15 0 empty empty 7 4 -6 1 12 -233017 -1 -1 0 1;
+#X obj 214 98 tgl 15 0 empty empty 8 4 -6 1 12 -233017 -1 -1 0 1;
+#X obj 231 98 tgl 15 0 empty empty 9 4 -6 1 12 -233017 -1 -1 0 1;
+#X obj 248 98 tgl 15 0 empty empty 10 0 -6 1 12 -233017 -1 -1 0 1;
+#X obj 265 98 tgl 15 0 empty empty 11 0 -6 1 12 -233017 -1 -1 0 1;
+#X obj 282 98 tgl 15 0 empty empty 12 0 -6 1 12 -233017 -1 -1 0 1;
+#X obj 299 98 tgl 15 0 empty empty 13 0 -6 1 12 -233017 -1 -1 0 1;
+#X obj 78 98 tgl 15 0 empty empty 0 4 -6 1 12 -233017 -1 -1 0 1;
+#X obj 95 98 tgl 15 0 empty empty 1 4 -6 1 12 -233017 -1 -1 0 1;
+#X obj 112 98 tgl 15 0 empty empty 2 4 -6 1 12 -233017 -1 -1 0 1;
+#X obj 129 98 tgl 15 0 empty empty 3 4 -6 1 12 -233017 -1 -1 0 1;
+#X obj 146 98 tgl 15 0 empty empty 5 4 -6 1 12 -233017 -1 -1 0 1;
+#X obj 163 98 tgl 15 0 empty empty 6 4 -6 1 12 -233017 -1 -1 0 1;
+#X obj 180 98 tgl 15 0 empty empty 7 4 -6 1 12 -233017 -1 -1 0 1;
+#N canvas 314 233 679 330 generate 0;
+#X obj 42 24 inlet;
+#X obj 82 24 inlet;
+#X obj 121 24 inlet;
+#X obj 161 24 inlet;
+#X obj 201 24 inlet;
+#X obj 241 24 inlet;
+#X obj 280 24 inlet;
+#X obj 320 24 inlet;
+#X obj 361 23 inlet;
+#X obj 401 23 inlet;
+#X obj 440 23 inlet;
+#X obj 480 23 inlet;
+#X obj 520 23 inlet;
+#X msg 42 66 digital 0 \$1;
+#X msg 82 88 digital 1 \$1;
+#X msg 121 110 digital 2 \$1;
+#X msg 161 130 digital 3 \$1;
+#X msg 201 62 digital 4 \$1;
+#X msg 241 84 digital 5 \$1;
+#X msg 280 106 digital 6 \$1;
+#X msg 320 126 digital 7 \$1;
+#X msg 361 58 digital 8 \$1;
+#X msg 401 80 digital 9 \$1;
+#X msg 440 102 digital 10 \$1;
+#X msg 480 122 digital 11 \$1;
+#X msg 520 50 digital 12 \$1;
+#X obj 559 23 inlet;
+#X msg 559 70 digital 13 \$1;
+#X obj 298 284 outlet;
+#X obj 298 245 trigger bang anything;
+#X obj 298 196 list prepend set;
+#X obj 298 220 list trim;
#X connect 0 0 13 0;
#X connect 1 0 14 0;
#X connect 2 0 15 0;
@@ -374,26 +309,27 @@ Arduino (previously known as Pduino firmware).;
#X connect 10 0 23 0;
#X connect 11 0 24 0;
#X connect 12 0 25 0;
-#X connect 13 0 28 0;
-#X connect 14 0 28 0;
-#X connect 15 0 28 0;
-#X connect 16 0 28 0;
-#X connect 17 0 28 0;
-#X connect 18 0 28 0;
-#X connect 19 0 28 0;
-#X connect 20 0 28 0;
-#X connect 21 0 28 0;
-#X connect 22 0 28 0;
-#X connect 23 0 28 0;
-#X connect 24 0 28 0;
-#X connect 25 0 28 0;
+#X connect 13 0 30 0;
+#X connect 14 0 30 0;
+#X connect 15 0 30 0;
+#X connect 16 0 30 0;
+#X connect 17 0 30 0;
+#X connect 18 0 30 0;
+#X connect 19 0 30 0;
+#X connect 20 0 30 0;
+#X connect 21 0 30 0;
+#X connect 22 0 30 0;
+#X connect 23 0 30 0;
+#X connect 24 0 30 0;
+#X connect 25 0 30 0;
#X connect 26 0 27 0;
-#X connect 27 0 28 0;
-#X connect 28 0 30 0;
-#X connect 30 0 29 0;
-#X connect 30 1 29 0;
+#X connect 27 0 30 0;
+#X connect 29 0 28 0;
+#X connect 29 1 28 0;
+#X connect 30 0 31 0;
+#X connect 31 0 29 0;
#X restore 78 122 pd generate digital out messages;
-#X obj 348 73 tgl 25 0 empty empty ALL 2 12 0 12 -262144 -1 -1 1 1
+#X obj 348 73 tgl 25 0 empty empty ALL 2 12 0 12 -262144 -1 -1 0 1
;
#X obj 349 34 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 16383
;
@@ -485,24 +421,22 @@ Arduino (previously known as Pduino firmware).;
#X restore 45 420 pd display values without pegging the CPU;
#X obj 397 389 route digital version;
#X obj 397 446 route 0 1 2 3 4 5 6 7 8 9 10 11 12 13;
-#X obj 414 468 tgl 15 0 empty empty 1 4 23 1 12 -232448 -1 -1 0 1;
-#X obj 431 468 tgl 15 0 empty empty 2 4 23 1 12 -232448 -1 -1 0 1;
-#X obj 448 468 tgl 15 0 empty empty 3 4 23 1 12 -232448 -1 -1 0 1;
-#X obj 465 468 tgl 15 0 empty empty 4 4 23 1 12 -232448 -1 -1 0 1;
-#X obj 482 468 tgl 15 0 empty empty 5 4 23 1 12 -232448 -1 -1 0 1;
-#X obj 499 468 tgl 15 0 empty empty 6 4 23 1 12 -232448 -1 -1 0 1;
-#X obj 516 468 tgl 15 0 empty empty 7 4 23 1 12 -232448 -1 -1 0 1;
-#X obj 533 468 tgl 15 0 empty empty 8 4 23 1 12 -232448 -1 -1 0 1;
-#X obj 550 468 tgl 15 0 empty empty 9 4 23 1 12 -232448 -1 -1 0 1;
-#X obj 567 468 tgl 15 0 empty empty 10 0 23 1 12 -232448 -1 -1 0 1
+#X obj 428 468 tgl 15 0 empty empty 2 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 445 468 tgl 15 0 empty empty 3 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 462 468 tgl 15 0 empty empty 4 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 479 468 tgl 15 0 empty empty 5 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 496 468 tgl 15 0 empty empty 6 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 513 468 tgl 15 0 empty empty 7 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 530 468 tgl 15 0 empty empty 8 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 547 468 tgl 15 0 empty empty 9 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 564 468 tgl 15 0 empty empty 10 0 23 1 12 -232448 -1 -1 0 1
;
-#X obj 584 468 tgl 15 0 empty empty 11 0 23 1 12 -232448 -1 -1 0 1
+#X obj 581 468 tgl 15 0 empty empty 11 0 23 1 12 -232448 -1 -1 0 1
;
-#X obj 601 468 tgl 15 0 empty empty 12 0 23 1 12 -232448 -1 -1 0 1
+#X obj 598 468 tgl 15 0 empty empty 12 0 23 1 12 -232448 -1 -1 0 1
;
-#X obj 618 468 tgl 15 0 empty empty 13 0 23 1 12 -232448 -1 -1 0 1
+#X obj 615 468 tgl 15 0 empty empty 13 0 23 1 12 -232448 -1 -1 0 1
;
-#X obj 397 468 tgl 15 0 empty empty 0 4 23 1 12 -232448 -1 -1 0 1;
#N canvas 0 22 454 304 raw 0;
#X obj 96 231 outlet;
#X obj 96 63 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
@@ -512,7 +446,7 @@ Arduino (previously known as Pduino firmware).;
#X connect 2 0 0 0;
#X restore 374 292 pd raw PWM;
#X text 2 514 (C) Copyright 2006 Free Software Foundation;
-#N canvas 0 22 443 216 ver 0;
+#N canvas 0 22 451 224 ver 0;
#X obj 23 7 inlet;
#X obj 250 100 cnv 15 145 17 empty \$0-version_cnv firmata_version_1.0
4 10 0 12 -203904 -1 0;
@@ -531,83 +465,157 @@ Arduino (previously known as Pduino firmware).;
#X connect 7 0 5 0;
#X connect 8 0 4 0;
#X coords 0 -1 1 1 145 17 1 250 100;
-#X restore 74 351 pd ver;
+#X restore 67 329 pd ver;
#X obj 456 409 unpack 0 0;
#X floatatom 456 429 5 0 0 0 - - -;
#X floatatom 513 429 5 0 0 0 - - -;
-#X connect 4 0 69 0;
+#N canvas 163 104 696 323 send-to-arduino------------------- 0;
+#X obj 49 24 inlet;
+#X obj 89 24 inlet;
+#X obj 128 24 inlet;
+#X obj 168 24 inlet;
+#X obj 208 24 inlet;
+#X obj 248 24 inlet;
+#X obj 287 24 inlet;
+#X obj 327 24 inlet;
+#X obj 368 23 inlet;
+#X obj 408 23 inlet;
+#X obj 447 23 inlet;
+#X obj 487 23 inlet;
+#X obj 527 23 inlet;
+#X msg 49 66 pinMode 0 \$1;
+#X msg 89 88 pinMode 1 \$1;
+#X msg 128 110 pinMode 2 \$1;
+#X msg 168 130 pinMode 3 \$1;
+#X msg 208 62 pinMode 4 \$1;
+#X msg 248 84 pinMode 5 \$1;
+#X msg 287 106 pinMode 6 \$1;
+#X msg 327 126 pinMode 7 \$1;
+#X msg 368 58 pinMode 8 \$1;
+#X msg 408 80 pinMode 9 \$1;
+#X msg 447 102 pinMode 10 \$1;
+#X msg 487 122 pinMode 11 \$1;
+#X msg 527 50 pinMode 12 \$1;
+#X obj 566 23 inlet;
+#X msg 566 70 pinMode 13 \$1;
+#X obj 305 282 outlet;
+#X obj 305 243 trigger bang anything;
+#X obj 305 196 list prepend set;
+#X obj 305 220 list trim;
+#X connect 0 0 13 0;
+#X connect 1 0 14 0;
+#X connect 2 0 15 0;
+#X connect 3 0 16 0;
+#X connect 4 0 17 0;
+#X connect 5 0 18 0;
+#X connect 6 0 19 0;
+#X connect 7 0 20 0;
+#X connect 8 0 21 0;
+#X connect 9 0 22 0;
+#X connect 10 0 23 0;
+#X connect 11 0 24 0;
+#X connect 12 0 25 0;
+#X connect 13 0 30 0;
+#X connect 14 0 30 0;
+#X connect 15 0 30 0;
+#X connect 16 0 30 0;
+#X connect 17 0 30 0;
+#X connect 18 0 30 0;
+#X connect 19 0 30 0;
+#X connect 20 0 30 0;
+#X connect 21 0 30 0;
+#X connect 22 0 30 0;
+#X connect 23 0 30 0;
+#X connect 24 0 30 0;
+#X connect 25 0 30 0;
+#X connect 26 0 27 0;
+#X connect 27 0 30 0;
+#X connect 29 0 28 0;
+#X connect 29 1 28 0;
+#X connect 30 0 31 0;
+#X connect 31 0 29 0;
+#X restore 329 116 pd send-to-arduino-------------------;
+#X obj 394 468 tgl 15 0 empty empty 0 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 411 468 tgl 15 0 empty empty 1 4 23 1 12 -232448 -1 -1 0 1;
+#X obj 394 468 cnv 15 15 15 empty empty Rx 1 10 0 11 -128992 -86277
+0;
+#X obj 411 468 cnv 15 15 15 empty empty Tx 1 10 0 11 -128992 -13381
+0;
+#X obj 329 97 tgl 15 0 empty empty 0 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 346 97 tgl 15 0 empty empty 1 3 -6 1 12 -260818 -1 -1 0 1;
+#X obj 329 97 cnv 15 15 15 empty empty Rx 1 10 0 11 -128992 -86277
+0;
+#X obj 346 97 cnv 15 15 15 empty empty Tx 1 10 0 11 -128992 -13381
+0;
+#X connect 4 0 66 0;
#X connect 5 0 4 0;
-#X connect 8 0 69 0;
+#X connect 8 0 66 0;
#X connect 9 0 19 2;
#X connect 10 0 19 1;
#X connect 11 0 43 1;
#X connect 12 0 47 1;
#X connect 14 0 16 0;
-#X connect 16 0 69 0;
-#X connect 17 0 69 0;
+#X connect 16 0 66 0;
+#X connect 17 0 66 0;
#X connect 18 0 17 0;
#X connect 27 0 43 1;
#X connect 28 0 43 0;
#X connect 43 0 44 0;
-#X connect 44 0 69 0;
-#X connect 45 0 69 0;
-#X connect 46 0 69 0;
-#X connect 47 0 72 0;
-#X connect 49 0 63 1;
-#X connect 50 0 63 2;
-#X connect 51 0 63 3;
-#X connect 52 0 63 4;
-#X connect 53 0 63 5;
-#X connect 54 0 63 6;
-#X connect 55 0 63 7;
-#X connect 56 0 63 8;
-#X connect 57 0 63 9;
-#X connect 58 0 63 10;
-#X connect 59 0 63 11;
-#X connect 60 0 63 12;
-#X connect 61 0 63 13;
-#X connect 62 0 63 0;
-#X connect 63 0 65 0;
-#X connect 65 0 69 0;
-#X connect 66 0 69 0;
-#X connect 67 0 66 0;
-#X connect 69 0 47 0;
-#X connect 69 0 93 0;
-#X connect 69 1 19 0;
+#X connect 44 0 66 0;
+#X connect 45 0 66 0;
+#X connect 46 0 66 0;
+#X connect 47 0 69 0;
+#X connect 49 0 92 2;
+#X connect 50 0 92 3;
+#X connect 51 0 92 4;
+#X connect 52 0 92 5;
+#X connect 53 0 92 6;
+#X connect 54 0 92 7;
+#X connect 55 0 92 8;
+#X connect 56 0 92 9;
+#X connect 57 0 92 10;
+#X connect 58 0 92 11;
+#X connect 59 0 92 12;
+#X connect 60 0 92 13;
+#X connect 62 0 66 0;
+#X connect 63 0 66 0;
+#X connect 64 0 63 0;
+#X connect 66 0 47 0;
+#X connect 66 0 88 0;
+#X connect 66 1 19 0;
+#X connect 69 0 70 0;
+#X connect 69 1 72 0;
+#X connect 70 0 71 0;
+#X connect 70 1 71 1;
+#X connect 70 2 71 2;
+#X connect 70 3 71 3;
+#X connect 70 4 71 4;
+#X connect 70 5 71 5;
+#X connect 70 6 71 6;
+#X connect 70 7 71 7;
+#X connect 71 0 20 0;
+#X connect 71 1 21 0;
+#X connect 71 2 22 0;
+#X connect 71 3 23 0;
+#X connect 71 4 24 0;
+#X connect 71 5 25 0;
+#X connect 71 6 67 0;
+#X connect 71 7 68 0;
#X connect 72 0 73 0;
-#X connect 72 1 75 0;
-#X connect 73 0 74 0;
-#X connect 73 1 74 1;
-#X connect 73 2 74 2;
-#X connect 73 3 74 3;
-#X connect 73 4 74 4;
-#X connect 73 5 74 5;
-#X connect 73 6 74 6;
-#X connect 73 7 74 7;
-#X connect 74 0 20 0;
-#X connect 74 1 21 0;
-#X connect 74 2 22 0;
-#X connect 74 3 23 0;
-#X connect 74 4 24 0;
-#X connect 74 5 25 0;
-#X connect 74 6 70 0;
-#X connect 74 7 71 0;
-#X connect 75 0 76 0;
-#X connect 75 1 94 0;
-#X connect 76 0 90 0;
-#X connect 76 1 77 0;
-#X connect 76 2 78 0;
-#X connect 76 3 79 0;
-#X connect 76 4 80 0;
-#X connect 76 5 81 0;
-#X connect 76 6 82 0;
-#X connect 76 7 83 0;
-#X connect 76 8 84 0;
-#X connect 76 9 85 0;
-#X connect 76 10 86 0;
-#X connect 76 11 87 0;
-#X connect 76 12 88 0;
-#X connect 76 13 89 0;
-#X connect 91 0 69 1;
-#X connect 94 0 95 0;
-#X connect 94 1 96 0;
+#X connect 72 1 89 0;
+#X connect 73 2 74 0;
+#X connect 73 3 75 0;
+#X connect 73 4 76 0;
+#X connect 73 5 77 0;
+#X connect 73 6 78 0;
+#X connect 73 7 79 0;
+#X connect 73 8 80 0;
+#X connect 73 9 81 0;
+#X connect 73 10 82 0;
+#X connect 73 11 83 0;
+#X connect 73 12 84 0;
+#X connect 73 13 85 0;
+#X connect 86 0 66 1;
+#X connect 89 0 90 0;
+#X connect 89 1 91 0;
+#X connect 92 0 62 0;
diff --git a/arduino.pd b/arduino.pd
index fb5a329..1ba579f 100644
--- a/arduino.pd
+++ b/arduino.pd
@@ -1,14 +1,12 @@
-#N canvas 365 27 676 408 10;
+#N canvas 365 27 636 363 10;
#X obj 377 9 import hardware flatspace iemlib mapping;
#X text 321 336 released under the GNU GPL;
#X obj 61 19 inlet;
#X obj 61 297 outlet;
#X obj 544 297 outlet;
-#N canvas 350 22 685 405 command 1;
+#N canvas 350 22 585 340 command 0;
#X obj 24 7 inlet;
#X obj 281 289 outlet;
-#X obj 210 93 clip 0 1;
-#X obj 210 114 int;
#N canvas 729 244 499 307 digital-out 0;
#X obj 26 12 inlet;
#X obj 218 219 outlet;
@@ -78,7 +76,6 @@
#X connect 13 0 12 0;
#X connect 13 1 1 0;
#X restore 280 93 pd pinMode;
-#X obj 210 135 + 150;
#N canvas 300 373 368 376 pwm 0;
#X obj 44 14 inlet;
#X obj 44 312 outlet;
@@ -105,7 +102,7 @@
#X obj 412 91 route digital version;
#X obj 24 51 route pwm analog analogIns digitalIns pinMode info;
#X msg 473 118 249;
-#N canvas 0 22 454 304 analogIns 0;
+#N canvas 0 22 458 308 analogIns 0;
#X obj 64 7 inlet;
#X obj 69 263 outlet;
#X obj 64 65 unpack float float;
@@ -131,26 +128,40 @@
#X connect 9 0 3 0;
#X connect 10 0 9 0;
#X restore 106 94 pd analogIns;
-#X connect 0 0 10 0;
+#N canvas 0 22 454 304 digitalIns 0;
+#X obj 98 26 inlet;
+#X obj 98 264 outlet;
+#X obj 98 89 select 0;
+#X msg 98 111 0;
+#X obj 143 110 bang;
+#X msg 143 131 1;
+#X msg 98 178 208 \, \$1;
+#X connect 0 0 2 0;
#X connect 2 0 3 0;
+#X connect 2 1 4 0;
#X connect 3 0 6 0;
+#X connect 4 0 5 0;
+#X connect 5 0 6 0;
+#X connect 6 0 1 0;
+#X restore 187 94 pd digitalIns;
+#X connect 0 0 7 0;
+#X connect 2 0 1 0;
+#X connect 3 0 1 0;
#X connect 4 0 1 0;
#X connect 5 0 1 0;
-#X connect 6 0 1 0;
-#X connect 7 0 1 0;
+#X connect 6 0 2 0;
+#X connect 6 1 8 0;
+#X connect 6 2 1 0;
+#X connect 7 0 4 0;
+#X connect 7 1 4 0;
+#X connect 7 2 9 0;
+#X connect 7 3 10 0;
+#X connect 7 4 3 0;
+#X connect 7 5 5 0;
+#X connect 7 6 6 0;
#X connect 8 0 1 0;
-#X connect 9 0 4 0;
-#X connect 9 1 11 0;
-#X connect 9 2 1 0;
-#X connect 10 0 7 0;
-#X connect 10 1 7 0;
-#X connect 10 2 12 0;
-#X connect 10 3 2 0;
-#X connect 10 4 5 0;
-#X connect 10 5 8 0;
-#X connect 10 6 9 0;
-#X connect 11 0 1 0;
-#X connect 12 0 1 0;
+#X connect 9 0 1 0;
+#X connect 10 0 1 0;
#X restore 61 52 pd command processing;
#X obj 319 19 inlet;
#X text 306 1 raw input;
@@ -163,7 +174,7 @@
#X connect 0 0 2 0;
#X connect 2 0 1 0;
#X restore 410 112 pd report object version;
-#N canvas 0 22 474 324 report 0;
+#N canvas 0 22 478 328 report 0;
#X obj 66 7 inlet;
#X obj 66 36 route open;
#X obj 66 60 select 1;
@@ -175,12 +186,12 @@
#X connect 4 0 3 0;
#X restore 231 113 pd report firmware version;
#X text 335 299 DEBUG/RAW data (this will change);
-#N canvas 225 71 451 405 make 0;
+#N canvas 225 71 467 421 make 0;
#X obj 79 6 inlet;
#X obj 184 337 outlet;
#X obj 79 72 moses 128;
#X obj 130 96 trigger float float;
-#N canvas 102 52 649 354 set 0;
+#N canvas 102 52 653 358 set 0;
#X obj 26 3 inlet;
#X obj 34 307 outlet;
#X text 85 31 0xF0;
@@ -216,7 +227,6 @@
#X connect 11 0 1 0;
#X connect 13 0 11 0;
#X connect 13 1 7 0;
-#X connect 13 2 14 0;
#X connect 15 0 14 0;
#X connect 16 0 1 0;
#X connect 17 0 14 0;
@@ -230,7 +240,7 @@
#X obj 117 188 - 1;
#X obj 79 128 trigger bang float;
#X text 140 72 only process command bytes;
-#N canvas 0 22 474 324 convert 0;
+#N canvas 0 22 482 332 convert 0;
#X obj 142 218 outlet;
#X obj 257 218 print UNKNOWN_INPUT_COMMAND;
#N canvas 123 202 630 307 digital 0;
@@ -287,7 +297,7 @@
#X connect 18 0 4 0;
#X connect 19 0 4 0;
#X restore 143 114 pd digital messages;
-#N canvas 134 58 331 263 analog 0;
+#N canvas 134 58 335 267 analog 0;
#X obj 65 6 inlet;
#X obj 65 203 outlet;
#X msg 65 180 analog \$1 \$2;
@@ -336,7 +346,7 @@
#X connect 9 1 5 0;
#X connect 11 0 1 0;
#X restore 62 199 pd make lists;
-#N canvas 0 22 521 265 check 0;
+#N canvas 0 22 525 269 check 0;
#X obj 47 62 inlet;
#X obj 47 88 route version;
#X obj 87 119 unpack float float;