Go Down

Topic: How to easily send data from one arduino to another? (Read 786 times) previous topic - next topic

Nick Gammon

Instead of:

Code: [Select]

  // If an input comes in from the other sensor, increment count and report the new score
  if((digitalRead(7) == HIGH)) {
   count++;
   i = count;
   report_score();
  }


You might have

Code: [Select]

  // If an input comes in from the other sensor, increment count and report the new score

  byte current_reading = digitalRead(7);
  static byte last_reading = LOW;     // static preserves values through each iteration

  if (current_reading == HIGH && last_reading == LOW)
   {
   count++;
   i = count;
   report_score();
   }

  last_reading  = current_reading;


That detects a change from LOW to HIGH. Otherwise you might add 1000 to count before the sending end took the line LOW again.

billroy

If you don't have the grounds of the two arduinos connected, there is no circuit.  You need one wire from the signal pin on A to the signal pin on B, and one wire from the ground on A to the ground on B.

-br

cat6

Bilroy:  Ohhhhhhh...yeah, that um...makes some sense.  I'll try that first.

Nick, I'll try your suggestion next and get back to both of you asap.

cat6

Yay!  It works!  See this awful pile of lego and electronics in all its now-functioning glory here:  http://www.youtube.com/watch?v=PsToWf5x1sQ&feature=plcp

Thanks again for the help, guys.

Go Up