encoding LEDs

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
sultaanofswing
 
Posts: 1
Joined: Mon Apr 13, 2009 12:49 am

encoding LEDs

Post by sultaanofswing »

I am using an attiny85V microcontroller and an avrisp mkII programmer to make an LED blink. For compiling, I am using AVR studio 4. I am trying to make the LED blink a number (in binary) such that it could be seen by a camera and decoded by a computer connected to the camera. (I am trying to track a mobile robot through a camera by putting a blinking LED on top of the robot).
For example, the LED could blink 0100010011 for the number 275. My question is how can I encode the attiny85V to make the LED blink such a number. Can anyone please give me a few lines of code or give me any ideas or point me to any resources to get started. Thanks a lot.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: encoding LEDs

Post by adafruit »

can you get the LED to blink at all?

The_Don125
 
Posts: 373
Joined: Tue Mar 06, 2007 11:51 pm

Re: encoding LEDs

Post by The_Don125 »

Heres an idea: If you aren't using PB0, then you could try this. You need an extra uint_8 variable, just in case your RAM usage was at its limit.

Basically, you store the value you want to encode into the variable, then you set that variable equal to portB, and finally right-shift the variable.

So, the pseudo-code probably would look something like:

Code: Select all

uint_8 encoded_val

loop forever
begin
for (8 times)
begin
PortB <= encoded_val
encoded_val = encoded_val >> 1
wait for some time
end
encoded_val <= next_value
end

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: encoding LEDs

Post by mtbf0 »

how are you going to see leading and trailing zeroes or will you use long and short pulses rather than on and off?

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”