Nano pins go low when written as high

I am not sure what the problem is, but when I run the following code, the LED connected to pin 5 does not blink. However, when I turn the LED around. It kind of works, but when the pin is low, the led turns on?! I have tried different variations of the code, different Nanos, different LEDs, but I always get the same result.

The entire circuit is just an LED with its cathode connected through a 220 ohm resistor to ground, and it anode connected to pin D5. You heard that right, the positive side of the LED is connected to ground, and it works!!!

I am not sure why this is happening, but I have been puzzling over it for the past three hours.

#define new_led 5

void setup() {
  pinMode(new_led,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(new_led,HIGH);
  Serial.println("on");
  delay(3000);
  digitalWrite(new_led,LOW);
  Serial.println("off");
  delay(3000);
}

Your LED wiring should be either that of D5 or D6.

What do you mean?

If your LED is wired similar to D5 then you need a LOW on the Arduino output to turn on the LED.

If your LED is wired similar to D6 then you need a HIGH on the Arduino output to turn on the LED.

You decide on what your requirements are :thinking:

I am still not able to get it to work...

Please show us a good image of your wiring.

More to the point, a good image of your LED. :roll_eyes:

If it works with the "anode" to negative, then you have clearly mis0identified the anode. :rofl:

I worked in a electronics factory 40+ years ago.

Every now and then we would get a run of diodes marked backwards.

Remember one PCB had one of these diodes installed backwards, it was passed in QC, after all it worked.

Which pins have internal pull down resistors?

The entire circuit is just an LED with its cathode connected through a 220 ohm resistor to ground, and it anode connected to pin D5.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.