Society of Robots - Robot Forum

Software => Software => Topic started by: AZ196F on June 05, 2007, 12:58:27 PM

Title: 50$ Robot Status LED
Post by: AZ196F on June 05, 2007, 12:58:27 PM
I'm looking at the code for the 50$ robot and wondering why turning port D4 off turns the LED on.  I think that if I could understand this, I might understand a lot more about i/o.
Title: Re: 50$ Robot Status LED
Post by: razvanc_roro on June 05, 2007, 01:01:10 PM
I understood that if you put D4 low, LED turns on. :)
Title: Re: 50$ Robot Status LED
Post by: Admin on June 05, 2007, 01:10:21 PM
When you wired up the LED, you have one end connected to + of the battery.

The other end is connected to D4.

So if D4 is also high (+), nothing will happen to the LED since both ends are + and +.

When you set D4 to low (-), you then have a voltage difference across the LED (+ and -), turning it on.


If you instead wired one LED end to ground (-), and the other to the D4 pin, when D4 goes high it is powering the LED - potentially bad. Its better to use the above method so that the battery directly powers the LED and not the microcontroller.
Title: Re: 50$ Robot Status LED
Post by: AZ196F on June 05, 2007, 01:12:04 PM
Thank you, that's exactly what I needed to know!  Much Thanks!