0

I have an Arduino Uno rev 3 and an Arduino Nano in my Setup. I want to create a proof of concept, where one Arduino triggers the other via the Digital IOs. Arduino 1 sets a blinking signal on a digital pin (500ms delay between high/low), which is received by arduino 2. If the signal is high, Arduino 2 triggers a LED (digital pin to LED+; LED- over 330 Ohm resistor to ground), so the signal gets looped through somehow. The grounds of the two Arduinos are connected, too.

Schematic

Code Arduino #1:

void setup() {
  DDRD |=_BV(PD7); //Sets Digital Pin 7 as Output
}

void loop() {
 PORTD |=_BV(PD7); // equivalent with digitalWrite(7, HIGH);
 delay(500);
 PORTD &=~_BV(PD7); // equivalent with digitalWrite(7, LOW);
 delay(500);
}

Code Arduino #2:

void setup() {
  DDRD &=~_BV(PD7); //Sets Digital Pin 7 as Input
  DDRD |=_BV(PB0); //Set Digital Pin 8 as Output
}

bool set = false;

void loop() {
  if((PIND&_BV(PD7))==_BV(PD7)) { //true if digital pin 7 is set
    if(!set) {
      //PORTB |= _BV(PB0);
      digitalWrite(8, HIGH);
      set = true;
    }
  } else {
    //PORTB &=~_BV(PB0);
      digitalWrite(8, LOW);
    set = false;
  }

}

But instead of emitting a bright light, which can be seen if connecting the blinking signal directly to the LED, it emits a faint light. The voltmeter also shows an significant Voltage drop. Whilst the digital pin should have a voltage of ~5V when set to HIGH (never reached because of inner resitance inside the arduino), it measures about 1.6-1.8V. I also switched the both Arduinos which showed the same result, so it shouldn't be a hardware defect.

Thanks in Advance!

5
  • 3
    Draw a schematic. That text description is very difficult to follow.
    – Matt Young
    Apr 10, 2015 at 13:08
  • How are the two arduino's powered and at what voltage?
    – Phil B.
    Apr 10, 2015 at 13:11
  • Both powered via USB, schematic is following
    – Matze
    Apr 10, 2015 at 13:27
  • While you're at it, show us the code that's running on Arduino #2 as well.
    – Dave Tweed
    Apr 10, 2015 at 13:34
  • Added Schematic and code sample
    – Matze
    Apr 10, 2015 at 13:54

2 Answers 2

3

the line DDRD |=_BV(PB0); should be DDRB |=_BV(PB0); currently PB0 is set as an input so when you set it high it is just turning on the pull-up resistor, which is basically adding another ~10k in series with the LED, hence the dim light.

1
  • Works like a charm, thanks i didn't see that one
    – Matze
    Apr 10, 2015 at 15:02
0

A couple of delays in the Arduido #2 if(!set) { } else { } might allow the LED to stay on long enough to be seen.

At the moment this is rapidly switching the LED whenever the digital pin7 is set.

2
  • Thought about that one too, but the else block is in another scope. The else condition reacts on wether or not the signal is set, and not the bool! The nested if(!set) has no else block and is encapsulated in the wrapping if. For simplification, you could add an else block containing a return.
    – Matze
    Apr 10, 2015 at 14:52
  • Misread that one.
    – Neomada
    Apr 10, 2015 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.