How to for: LED Radiation Badge
Please note: that this is provided for informational purposes only and you should be careful when working with any kind of electricity, as it can be dangerous if you are not carefull.
Since the theme of our haunted house theme this year is an alien invastion, I wanted to make some interesting badges we could wear. This one is a simulated radiation detector, with an led bar graph that counts up and resets. Looking like there is a rise in radiation.
I decided to use a PIC18F2550 microcontroller because it has enough outputs to control the leds I want, can be programmed in basic, and has a small foot print, it also can be run on 3 volts. Basically all you have to do is connect the output pins of your microcontroller to the positive pins of the leds of the segment graph. I wanted the smallest parts count possible for this project, and with only 5 parts making up the circuit it works well. The card is still almost flat and can worn with out a problem. The 10k pullup resistor is placed directly on top of the chip and solder directly to the pins, and the pic chip is connected directly led chip.
To wire the lights up, you connect one side all together, this is your negative side, Each of the lights will connect to one pin of the microcontroller so that it can address each one individually.
I used swordfish compiler to program the chip, because I like coding in basic. The program is very simple and is designed to turn the lights on and off.
CODE:
This is the code that i used to control the Badge, all it does it set up the pins on the microcontroller and then turns them on and off in which ever order is programmed in.
Device = 18F2550
Clock = 8
Config FOSC = INTOSCIO_EC
Include "utils.bas"
Dim LED1 As PORTB.7
Dim LED2 As PORTB.6
Dim LED3 As PORTB.5
Dim LED4 As PORTB.4
Dim LED5 As PORTB.3
Dim LED6 As PORTB.2
Dim LED7 As PORTB.1
Dim LED8 As PORTB.0
// Start Of Program...
OSCCON = %01111111 // Sets up the internal oscillator
SetAllDigital // Make all Pins digital I/O's
// Make the LED pin an output and
Low(LED1)
Low(LED2)
Low(LED3)
Low(LED4)
Low(LED5)
Low(LED6)
Low(LED7)
Low(LED8)
While True
LED1 = 1
DelayMS(200)
LED1 = 0
DelayMS(200)
LED1 = 1
DelayMS(200)
LED1 = 0
DelayMS(200)
LED1 = 1
DelayMS(200)
LED1 = 0
DelayMS(200)
LED1 = 1
DelayMS(200)
LED1 = 0
DelayMS(200)
LED1 = 1
DelayMS(200)
LED1 = 0
DelayMS(200)
LED1 = 1
DelayMS(600)
LED2 = 1
DelayMS(600)
LED3 = 1
DelayMS(600)
LED4 = 1
DelayMS(600)
LED5 = 1
DelayMS(600)
LED6 = 1
DelayMS(600)
LED7 = 1
DelayMS(600)
LED8 = 1
DelayMS(600)
LED8 = 0
DelayMS(100)
LED8 = 1
DelayMS(100)
LED8 = 0
DelayMS(100)
LED8 = 1
DelayMS(100)
LED8 = 0
DelayMS(100)
LED8 = 1
DelayMS(100)
LED8 = 0
DelayMS(100)
LED8 = 1
DelayMS(100)
LED8 = 0
DelayMS(100)
PORTB = %00000000
Wend
What you will need:
1. Printed Badge of your choosing
2. PIC18F2550 (PICKIT 2 or other programmer)
3. 10 Segment LED Bar graph
4. 10 K Resistor
5. 2032 3 volt battery and holder
6. glue
7. Tools, Soldering iron, wire cutters
8. Wire
Programming and card prep::
Finished:
Any questions or comments email: joshua14ss@hotmail.com
Copyright 2011: Joshua T. Webb