Thursday, 15 August 2013

PIC 12F683 Based LED Chaser

The heart of the LED chaser is the PIC 12F683 microcontroller. The price of this chips makes it very attractive for small projects. The program that runs on this chip controls the LEDs attached to the output port pins. Resistors R1 thru R5 limit the current through LED1 - LED5 to a safe level that won't damage the PICs I/O ports or LED's. Capacitor C1 is used to decouple the 5 volt power supply to the PIC. Input voltage for the LED chaser should be between 3 volts and 5 volts. The 12F chips have an internal 4 Mhz oscillator and can be configured for internal, which reduces the number of external components, and makes more pins available for I/O. The internal clock is sufficiently accurate for blinking a LED. Programming is done in JAL Edit. JAL (Just Another Language) is an open source programming language built for programming PIC micro-controllers.

PIC12F683 LED Chaser Circuit Diagram

 

PARTS LIST

PIC12F683 - 1
Resistors
R1 - R5 - 470 Ohms
LED
D1 -D5 - Red LED
Capacitor
C1 - 0.1µF Disc

Common board
Connector
Wire
 
PIC 12F683 based LED Chaser JAL Edit code
include 12f683                     -- Target PICmicro
pragma target clock  8_000_000     -- Oscillator frequency
-- Configuration memory settings (fuses) ---------------------------------------
pragma target OSC  INTOSC_NOCLKOUT -- Internal oscillator
pragma target WDT  disabled        -- No watchdog
pragma target MCLR internal        -- Make MCLR pin available I/O
pragma target PWRTE enabled        -- Power On Reset enabled
pragma target BROWNOUT enabled     -- Brown-out detect enabled
OSCCON_IRCF = 0b_111               -- Internal Oscillator Frequency Select bits
                                   -- 111 = 8MHz
                                   -- 110 = 4 MHz (default)
                                   -- 101 = 2MHz
                                   -- 100 = 1MHz
                                   -- 011 = 500kHz
                                   -- 010 = 250kHz
                                   -- 001 = 125kHz
                                  
enable_digital_io()                -- Disable analog I/O (if any)
include delay                      -- Load delay Library
-- Declare in/out pins ---------------------------------------------------------
        pin_A0_direction=output
        pin_A1_direction=output
        pin_A2_direction=output
        pin_A4_direction=output
        pin_A5_direction=output
        pin_A0=false
        pin_A1=false
        pin_A2=false
        pin_A4=false
        pin_A5=false
       
-- Extras ----------------------------------------------------------------------
        var word d = 200           -- 200ms delay
-- Main ------------------------------------------------------------------------
forever loop
        pin_A0=true
        pin_A1=false
        pin_A2=false
        pin_A4=false
        pin_A5=false
        delay_1ms(d)
--------------------------------------------------------------------------------
        pin_A0=false
        pin_A1=true
        pin_A2=false
        pin_A4=false
        pin_A5=false
        delay_1ms(d)
--------------------------------------------------------------------------------
        pin_A0=false
        pin_A1=false
        pin_A2=true
        pin_A4=false
        pin_A5=false
        delay_1ms(d)
--------------------------------------------------------------------------------
        pin_A0=false
        pin_A1=false
        pin_A2=false
        pin_A4=true
        pin_A5=false
        delay_1ms(d)
--------------------------------------------------------------------------------
        pin_A0=false
        pin_A1=false
        pin_A2=false
        pin_A4=false
        pin_A5=true
        delay_1ms(d)
       
end loop
-- End -------------------------------------------------------------------------
Please copy and paste HEX code into notepad and save as " Chaser.hex ".

PIC 12F683 based LED Chaser HEX code
:020000040000FA
:100000008F3083160F0570388F009F0183129F0178
:10001000073099009A012D282608A8002708A90072
:10002000AA01AB012428831203130330A0008330FC
:10003000A1000A128A11A10B19280A128A11A00B19
:100040001728AA0A0319AB0A2A082802A0002B08BD
:1000500029022004031D13280800831605108510AB
:100060000511051285128312231023088500A310A1
:100070002308850023112308850023122308850007
:10008000A31223088500C830A400A50183122314FD
:1000900023088500A3102308850023112308850069
:1000A000231223088500A312230885002408A60034
:1000B0002508A7000C208312231023088500A31411
:1000C00023088500231123088500231223088500B7
:1000D000A312230885002408A6002508A7000C20E9
:1000E0008312231023088500A310230885002315FD
:1000F00023088500231223088500A3122308850006
:100100002408A6002508A7000C208312231023082A
:100110008500A310230885002311230885002316DA
:1001200023088500A312230885002408A6002508BB
:10013000A7000C208312231023088500A310230896
:100140008500231123088500231223088500A316A8
:10015000230885002408A6002508A7000C204628AF
:02400E00C43FAD
:00000001FF

No comments:

Post a Comment