inverded result Led13

Hi, I’m new in Arduino programming and I’ve started from the blink programm exemple.

I’ve changed some actions etc in order to test my programming skills and trying to understand Arduino.
I had lot of fun changing the rythms of blinking by differents ways.

Now I have something going wrong and I need some help.

In my sketch I declared the 13th pin mode asOUTPUT and put it in LOW:

void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
}

The “L” led in the card is Off. That’s what I espect.

I have a wire connexion from the 3.3V, a resistance, a Led (Anode) going to the 13th Pin.

It seems to me that the connection is ok. But the led lights On.

If I put digitalWrite(13, HIGH); the “L” turns on and my led turns of.

Is there a mistake I don’t see or maybe an invertion in the card parameters?
Could someone help me in this, please?

Thanks for your help.

In this case:

making pin 13 low will connect the resistor and LED to ground and complete the circuit, therefore lighting the LED. If pin 13 is high, both sides of the LED will be at the same potential, so current will not flow and the LED won't light.

In this case:

making pin 13 high will provide the resistor and LED 5V (or 3.3V) and the circuit will be completed to ground, therefore lighting the LED. If pin 13 is low, both sides of the LED will be grounded, so current will not flow and the LED won't light.

Does that make sense?

Switching the low side is often better from a design perspective - many microcontrollers (including some of the new Arduino's, like the due and 101) are better at sinking current than sourcing it, as are many other IC's (manufacturing process is easier), so it's a good habit to get into.

RBandeira:
Hi, I'm new in Arduino programming and I've started from the blink programm exemple.

I've changed some actions etc in order to test my programming skills and trying to understand Arduino.
I had lot of fun changing the rythms of blinking by differents ways.

Now I have something going wrong and I need some help.

In my sketch I declared the 13th pin mode asOUTPUT and put it in LOW:

void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
}

The "L" led in the card is Off. That's what I espect.

I have a wire connexion from the 3.3V, a resistance, a Led (Anode) going to the 13th Pin.

It seems to me that the connection is ok. But the led lights On.

If I put digitalWrite(13, HIGH); the "L" turns on and my led turns of.

Is there a mistake I don't see or maybe an invertion in the card parameters?
Could someone help me in this, please?

Thanks for your help.

(Always) combine your software (code) with hardware device (schematic) .
Check the LED 13 hardware actual connection and its driver which INVERTS the processor output.
Hence - software HIGH turns LED off and vice verse.
Good luck.

Hi,
Thanks for Your comments. As I Said I'm new and now I can clearly see my mistake.

Dmjlambert schema is clear and I realise that the pinMode() puts
13th pin on OUTPUT. If I have a 5V in "one hand" I just need to find the ground.

My question is a tipicaly silly beginner mistake, but it's a good way to learn. :wink:

DrAzzy I'll try to get those good habits.

And Vaclav, I need more practice in the electronic schemas and connections.
In fact I have more practice programming then connecting.

Anyway, I thanks all you for your help.

"And Vaclav, I need more practice in the electronic schemas and connections.
In fact I have more practice programming then connecting."

No problem, as long as you keep in mind that your are not "software guru" only.
I had a boss who was startled by our whole group of "software engineers " (per HR job description ) capability to install hardware ( connect / wire PC to the telephone switch ) and than install and run software.

And than debug the whole setup.
Cheers