Line 30: | Line 30: | ||
== the arduino code that I am using: == | == the arduino code that I am using: == | ||
// a place to hold pin values | |||
int x = 0; | int x = 0; | ||
void setup() | void setup() | ||
{ | { | ||
Serial.begin(115200); | Serial.begin(115200); | ||
delay(600); | delay(600); | ||
digitalWrite(13,LOW); | digitalWrite(13,LOW); | ||
pinMode(13,INPUT); | pinMode(13,INPUT); | ||
} | } | ||
// Check serial buffer for characters | // Check serial buffer for characters | ||
// 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 | |||
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); | ||
Line 60: | Line 60: | ||
// 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); | ||
Line 74: | Line 74: | ||
} | } | ||
} | |||
} | } | ||
// 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); | ||
} | } |