More wood chuck lighting questions


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: More wood chuck lighting questions

    This is it. Enjoy. Sorry about formatting. Long story.

    '************************************************* ***************
    '* Name : Randomize 20 LEDs.BAS *
    '* Author : Greg Browne *
    '* Notice : Copyright (c) 2011 Not a chance *
    '* : All Rights Reserved *
    '* Date : 08/30/2011 *
    '* Version : 1.0 *
    '* Notes : 12f683 w/ nap to conserve power and various *
    '* : lighting sequences *
    '************************************************* ***************
    ' needs to be streamlined for cleaner reading
    clear
    define osc 4

    ' ------------------------------------turn off some stuff to save a little power
    @ device mclr_off 'start button is connected here
    @ device bod_off
    @ device fcmen_off
    @ device ieso_off
    @ device intrc_osc_noclkout
    @ device pwrt_on
    @ device protect_off

    ansel = 0
    cmcon0 = 7
    adcon0 = 0

    ' --------------------------------------------------------------- some variables
    delay2 var word
    myword var word

    delay var byte
    mybyte var byte
    previous_random var byte
    gpiostate var byte
    tristate var byte
    i var byte
    j var byte
    k var byte
    l var byte

    ' ------------------------------------------------------------------ some values
    delay = 50
    delay2 = 500

    '------------------------------------------------------------finally the program
    starthere:
    if gpio.3 = 1 then goto main
    nap 4 'naps for 288 milliseconds

    goto starthere

    '--------------------------------------------flash them all to make it look cool
    main:
    for i = 1 to 20
    random myword
    mybyte = (myword//20)
    if previous_random = mybyte then goto main
    gosub high_led
    pause delay
    gpio = %000000
    pause delay
    previous_random = mybyte
    next i
    '---------------------------------------------------------------- first 13 boxes
    mybyte = 0' start LEDs in sequence
    for mybyte = 0 to 12
    gosub high_led
    pause delay2*2
    gpio=%000000
    pause delay
    next mybyte

    '---------------------------------------------------------- four stars real fast
    mybyte = 13' beginning of stars
    for j = 1 to 4
    for mybyte = 13 to 16
    gosub high_led
    pause delay2/5
    gpio=%000000
    pause delay
    next mybyte
    next j
    '---------------------------------------- four stars with another blinking twice
    mybyte = 13' beginning of stars
    for mybyte = 13 to 17 ' with the HUD glass this time
    gosub high_led
    pause delay2
    gpio=%000000
    pause delay
    next mybyte
    ' ---------------------------------------blinks these lights k number of times
    mybyte = 17
    for k= 1 to 3
    gosub high_led
    pause 500
    gpio = 0
    pause 100
    next k
    '-----------------------------------now for the flag and name//take this out ???
    ' mybyte = 18' show them off a little
    'for mybyte = 18 to 19
    ' gosub high_led
    ' pause delay2
    ' gpio=%000000
    ' pause delay
    'next mybyte
    '----------------------------------------light american flag first then name tag

    trisio = %001111
    gpio = 0
    for l = 0 to 255 step 5' led18 gpio.4
    pwm gpio.4,l,10' light number 18, l intensity step, 10 usec
    next l

    for l = 255 to 0 step -5
    pwm gpio.4,l,10
    next l

    trisio = %001111

    for l = 0 to 255 step 5 'led 19 is gpio.5
    pwm gpio.5,l,10' light number 19, l intensity step, 10 usec
    next l

    for l = 255 to 0 step -5
    pwm gpio.5,l,10
    next l

    '----------------------------------------------------------------turn it all off
    gpio = 0
    trisio = %111111
    ' -----------------------------------------------------------send it back to nap
    goto starthere

    high_led:
    lookup mybyte,[%000001,%000010,%000001,%000100,%000001,%010000,%0 00001,%100000,%000010,%000100,%000010,%010000,%000 010,%100000,%000100,%010000,%000100,%100000,%01000 0,%100000],gpiostate
    gpio = gpiostate
    lookup mybyte,[%111100,%111100,%111010,%111010,%101110,%101110,%0 11110,%011110,%111001,%111001,%101101,%101101,%011 101,%011101,%101011,%101011,%011011,%011011,%00111 1,%001111],tristate
    trisio = tristate
    return

    end

  2. #2
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: More wood chuck lighting questions

    Like SteveB said...
    "any chance of seeing a photo of your project??" or even a drawing of the LED layout or just describe it...

    Thanks for the code... but it would be nice to see how you arranged the LED's.
    Specifically how each LED is laid out. You could possibly number the led's in the schematic and then show how they should be arranged.

    Thanks

    PS... the next time you post code use the "#" button at up on the message tool bar and it will put your code in a scrolling window.
    Last edited by Heckler; - 7th September 2011 at 02:48.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  3. #3
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: More wood chuck lighting questions

    Attached is the shematic, outline drawing and code for the plaque.

    It was an interesting project to control that many LEDs (20) with only 5 pins.

    If there is any further clarification needed or more info desired please ask.
    Attached Images Attached Images   
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: More wood chuck lighting questions

    Moved from Schematics.

    Robert

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts