go away spammer

Author Topic: $50 Robot: LED Logic  (Read 1904 times)

0 Members and 1 Guest are viewing this topic.

Offline GophermofurTopic starter

  • Jr. Member
  • **
  • Posts: 9
  • Helpful? 0
$50 Robot: LED Logic
« on: March 24, 2010, 08:32:24 AM »
I'm trying to understand the logic behind how the LED functions and why exactly we're doing it the way we are in the $50 robot tutorial.

In the tutorial, it shows VCC goes to positive LED pin. Negative led pin goes to resistor which goes to Microcontroller. Understood.
VCC-->
  • LED[-]-->resistor-->Some Port on Atmega8


What I don't understand is, why does switching off the port enable to LED to light up? I'm rather new to the concept of electrical flow through electronics, but as far as I understand, VCC will send a current through the LED which goes out through the negative lead, into the resistor and attempts to then hit the MCU. Does turning the port low somehow ground the connection and allow the LED to turn on? If that's the case, what does turning the port on do in terms of the electrical circuit that forces the LED to stay off (or rather, not make a connection to ground)?

Is there a reason this approach was taken rather than connecting port X on the MCU to the positive lead on the led and connecting the negative lead of the LED to ground (after hitting a resistor)? It seems more intuitive to me that way, but I figured there was a reason this approach was taken.

Atmega8-->
  • LED[-]-->resistor-->GND


Thanks!

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
    • Current projects
Re: $50 Robot: LED Logic
« Reply #1 on: March 24, 2010, 09:04:08 AM »
Electronic is not my specialty but I will try to explain. If I'm wrong Soeren will correct me ;)

The LED stays off when the pin is high because there is no electricity flowing through it. Why? Because for electricity to flow
you need a difference of potential between to two leads of the led. Since they are both at 5V, difference is 0 and electricity does flow.

Now why it is done this way? I think it's because it's easier for a MCU to "sink" current (switch the pin to the ground") than to "source" current (provide current).
By easier I mean the MCU can sink a lot more current than it can source.

Hope this help,

Chelmi.

Offline GophermofurTopic starter

  • Jr. Member
  • **
  • Posts: 9
  • Helpful? 0
Re: $50 Robot: LED Logic
« Reply #2 on: March 24, 2010, 09:14:09 AM »
That makes a ton of sense! Thanks!   :)

 


Get Your Ad Here

data_list