397
edits
Line 44: | Line 44: | ||
// If an 'r' is received then read the pins | // If an 'r' is received then read the pins | ||
// Read and send analog pins 0-5 | // Read and send analog pins 0-5 | ||
void loop() | void loop() | ||
{ | { | ||
if (Serial.available() > 0){ | if (Serial.available() > 0){ | ||
if (Serial.read() == 'r') { | if (Serial.read() == 'r') { | ||
for (int pin= 0; pin<=5; pin++){ | for (int pin= 0; pin<=5; pin++){ | ||
x = analogRead(pin); | x = analogRead(pin); | ||
sendValue (x); | sendValue (x); | ||
} | } | ||
// Read and send digital pins 2-13 | // Read and send digital pins 2-13 | ||
// Send a carriage returnt to mark end of pin data. | // Send a carriage returnt to mark end of pin data. | ||
// add a delay to prevent crashing/overloading of the serial port | // add a delay to prevent crashing/overloading of the serial port | ||
for (int pin= 2; pin<=13; pin++){ | for (int pin= 2; pin<=13; pin++){ | ||
x = digitalRead(pin); | x = digitalRead(pin); | ||
sendValue (x); | sendValue (x); | ||
} | } | ||
Serial.println(); | Serial.println(); | ||
delay (5); | delay (5); | ||
} | } | ||
} | } | ||
} | } | ||
// function to send the pin value followed by a "space". | // function to send the pin value followed by a "space". | ||
void sendValue (int x){ | void sendValue (int x){ | ||
Serial.print(x); | Serial.print(x); | ||
Serial.write(32); | Serial.write(32); | ||
} | } | ||
== my Max msp (Max for Live) patch: == | == my Max msp (Max for Live) patch: == |
edits