Pin13 goes HIGH/LOW but pin9 does NOT

Hi All.

I have a very simple piece of code switching 2 LEDS on and off, running in loop() with delay(2000) in between.

      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      delay(2000);
      digitalWrite(ledPin1, LOW);
      digitalWrite(ledPin2, LOW);
      delay(2000);

… BUT, only pinout 13 lights up. Pinout 10 does nothing.

Checks made:

  • Both LED’s work; I’ve swapped their positions.
  • I have checked the circuit with a multimeter and the parts in it.
  • I have measured the voltage between pinout 9 and GND. That remains at zero. I’m expecting the PD at pinout 9 to be almost 5Volts…

WHY does pinout 9 not go HIGH? WHY is there no voltage in pinout 9?

Can you help?

Here’s the full code:

// Simple idea from GolamMostafa

#include <SoftwareSerial.h>
SoftwareSerial BTserial(5, 6); // RX | TX
#define ledPin1 13    //built-in LED (L) of UNO
#define ledPin2 9  

void setup()
{
  Serial.begin(9600);
  BTserial.begin(9600);
  pinMode(ledPin1, OUTPUT);
  digitalWrite(ledPin1, LOW);
  pinMode(ledPin2, OUTPUT);
  digitalWrite(ledPin2, LOW);
}

void loop()
{
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      delay(2000);
      digitalWrite(ledPin1, LOW);
      digitalWrite(ledPin2, LOW);
      delay(2000);
}

Backround: I am trying to set up the logic to use an HC-05 as a controller. The aim is to send two command strings via the HC-05 to switch a pinout from LOW to HIGH. The RISING will trigger a time-stamp on a separate board.

My IDE is Arduino 1.8.5, running on Linux, Fedora28.

Look forward to your replies
Thanks
EGB

You've made some mistake in the wiring or the hookup. It's not the code. That code should blink both leds.

This probably isn't your problem, however, I would recommend changing whatever you are using software serial for over to hardware serial if possible as it may fix future problems due to not having interrupts with hardware serial on pin 0 and 1.

One thing to try: have you tried changing pin nine on the arduino to a different pin, say pin 8. It may be a problem with the arduino board itself.

--DH

Delta_G:
You've made some mistake in the wiring or the hookup. It's not the code. That code should blink both leds.

Okay, Delta_G. You are right.

I have just measured the voltage directly between Pin9 and GND. It is alternately running at zero or 4.94volts. Re-configuring the wiring lights up pin9. SOLVED.

Oh what a big lesson. These kinds of bugs - particularly circuit bugs - poor connections, etc - are costing me such a lot of time and heartache.

Thanks a million
EGB

SOLVED

DH12043:
... I would recommend changing whatever you are using software serial for over to hardware serial if possible as it may fix future problems due to not having interrupts with hardware serial on pin 0 and 1.

One thing to try: have you tried changing pin nine on the arduino to a different pin, say pin 8. It may be a problem with the arduino board itself.
--DH

Hi DH.

Yes, I'm discovering that there are options with the basic configurations:

  • SoftwareSerial with RX[HC-05] directly into TX[Arduino]
  • SoftwareSerial with RX[HC-05] crossing a 1K/2K bridge to reduce its volatge to 3.3 at the TX[Arduino]
  • Hardware with RX[HC-05] directly into TX[Arduino]
  • Hardware with RX[HC-05] crossing a 1K/2K bridge to reduce its volatge to 3.3 at the TX[Arduino]

They all offer different opportunities/functions/risks. I am slowly coming to understand the differences. Too slowly!!

I think I will post a NEW TOPIC with that question.

Thanks for the idea. I will do what you recommend.

About switching pins. I did that, but it now seems that the common issue was my breadboard and its wiring.

Thanks
EGB

SOLVED!

Alright, glad to be of help!