Tuesday, September 13, 2016

Blinking LED in pattern

Bob Blick arguably the first person who come out with the propeller clock. It is a 7 led that spin on a rotor and giving the illusion effect of numbers (clock time) in the air.
Image result for bob blick propeller clock
Original link: seem to be expired
Another link: Still active

It is around 14 years ago.
Now the internet is flooded with propeller led imaging projects. Even the market is selling the propeller led image device at relatively cheap price.

Well, cheap but it is not satisfying until you diy it yourself.

Basic ingredients:
leds - 8
mcu - use the development kit (pic18f4553)
power supply - source from pc usb port
jumper wire - 9
propeller - use your hand, moving up and down

Problems encountered:
I am using the ultra bright led, plus cant find suitable resistor. So no limiting current resistor is used and the ultra bright is really annoying. Pain in the eye when you have direct contact with it.
In the end, i use the phone to do video recording and monitor the output afterwards.

Hardware connection:

my development board has output pin for lcd 16x2, so direct connect from lcd 16x2 pins to breadboard is the simplest way.

Now, start to design my character:
Each character is at the 8x5 pattern configuration. Below is my designation 'A', 'B', 'C'.

Character ‘A’

0b00000,
0b01110,
0b10001,
0b10001,
0b10001,
0b11111,
0b10001,
0b10001
Character ‘B’

0b00000,
0b11110,
0b10001,
0b10001,
0b11110,
0b10001,
0b10001,
0b11110

Character ‘C’

0b00000,
0b01110,
0b10001,
0b10000,
0b10000,
0b10000,
0b10001,
0b01110

And then, convert it to hexadecimal (just for better view and shorter code)
A - 0x3E, 0x48, 0x48, 0x48, 0x3E,
B - 0x36, 0x49, 0x49, 0x49, 0x7F,
C - 0x22, 0x41, 0x41, 0x41, 0x3E,

For each character, I will add some blank spaces, just to distinguish each of the character,
And I will get something like this:
 rom char string[30] = {  
      0x3E, 0x48, 0x48, 0x48, 0x3E,   
      0x00, 0x00, 0x00, 0x00, 0x00,   
      0x36, 0x49, 0x49, 0x49, 0x7F,   
      0x00, 0x00, 0x00, 0x00, 0x00,   
      0x22, 0x41, 0x41, 0x41, 0x3E,  
      0x00, 0x00, 0x00, 0x00, 0x00,  
 }  

Next is the blinking pattern is single direction or bi direction,
single direction - blink according to the data in array from 0 to 30, then start from 0 again.
bi direction -  blink according to the data in array from 0 to 30, then count back, from 30 to 0.
 #ifdef UNIDIRECTION  
           i++;  
           if(i > 30) i = 0;  
 #endif  
 #ifdef BIDIRECTION  
           if(direction == 0){  
                i++;  
                if(i > 30) direction = 1;  
           }  
           else{  
                i--;  
                if(i < 0) direction = 0;  
           }  
 #endif  

I didnt know which solution is the best, so up to the user to decide.

3rd is the delay timing, using the try and error method, in the end i use 2.2 mili second.
Maybe not so accurate because I am using the delay loop instead of interrupt.

4th, shaking your hand "up and down" or "left and right", preferably is "left and right". However, moving your hand "up and down" can be more consistent than "left and right".

5th, face the mirror, move the hand at different timing until you can get the correct timing. This will be tiring.

Output:

Well, the message just came out wrong. so wrong....
but i dont have other pic. so.....dont misunderstood.

Conclusion:
It is harder than it look to get the correct moving timing using your hand.
And I actually took video, then browse the video in laptop, and pause every moment until i get the visible and clear character. Yeah, I cheat.
I will let it be like this for current stage. I will improve it at next blog (if i have time).

Project file and source code: LINK



No comments:

Post a Comment