462
edits
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; | |||
void setup() | void setup() | ||
{ | { | ||
Serial.begin(115200); | Serial.begin(115200); | ||
delay(600); | delay(600); | ||
digitalWrite(13,LOW); | digitalWrite(13,LOW); | ||
Line 45: | Line 43: | ||
// Check serial buffer for characters | |||
// 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 59: | Line 60: | ||
// Read and send digital pins 2-13 | |||
// Send a carriage returnt to mark end of pin data. | |||
// 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); | ||
} | } | ||
Line 74: | Line 77: | ||
} | } | ||
// function to send the pin value followed by a "space". | |||
void sendValue (int x){ | |||
Serial.print(x); | Serial.print(x); | ||
Serial.write(32); | Serial.write(32); | ||
} | } |
edits