Disco lighting controller - again


Closed Thread
Results 1 to 4 of 4
  1. #1
    malc-c's Avatar
    malc-c Guest

    Default Disco lighting controller - again

    I have been developing this version of my disco light controller, and learing a lot about electronics an pbp along the way. However I've hit a small problems with getting LEDs to chase correctly to the beat of the music.

    I have managed to filter the base beat using an NE555 and this provides a nice +5 logic pulse in time with the beat. However I'm finding that using the code below the lights cycle through the sequence too quick. What I'm after is for the LEDs to step through the sequence one at a time, where as at the moment it loops round, still finds the beat is present and jumps another setp, loops round again and does the same, until the beat isn't present. Whilst I could put in a larger pause, this could then cause problems of the code missing a beat on tracks with a faster beat. Is there anyway to detect just the initial change from low to high of the pin, thus ignoring the remainder of the time the pin is high, and then reset itself when the pin goes low again ? Or would this be too complicated ??

    Here's the code for the music section

    Code:
    music:
    
    read patt[swcount],steps                ;read the first value of the selected patter and place it in the variable steps
        READ PATT[SWCOUNT]+ C,PORTB         ;reads the step value for selected pattern and send it to PORTB 
               If switch2=1 then C=C+1
               pause 10
               If C=steps then C=1
    goto music:

  2. #2
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default Wait for the beat to go low.

    Hi Malc

    Assuming your PIC doesnt need to do anything else until the next beat then wait for the beat to disappear

    Code:
    music:
    
    read patt[swcount],steps                ;read the first value of the selected patter and place it in the variable steps
        READ PATT[SWCOUNT]+ C,PORTB         ;reads the step value for selected pattern and send it to PORTB 
               If switch2=1 then C=C+1
               pause 10
               If C=steps then C=1
             ****** add a bit here ******
    goto music:
    Add these lines at the point shown or if you need to update the display first then add the after you have updated the display.

    Code:
            While Switch2=1   ' beat signal is still high
                pause 1          ' short pause
            Wend                 ' its gone low now so we can carry on
    Hope that helps
    Keith

    www.diyha.co.uk
    www.kat5.tv

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks again mate,

    I'll give it a try later and let you know how well it works

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Or you poll an interrupt flag. Some interrupts source can be triggered by a rising OR falling edge. This said, it save few bytes of code.

    Food for thought
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Microstepper controller
    By aratti in forum Schematics
    Replies: 14
    Last Post: - 3rd January 2015, 16:52
  2. Temperature Controller using PIC16F628A
    By bentech4u in forum mel PIC BASIC
    Replies: 34
    Last Post: - 14th March 2010, 19:44
  3. problem with the GSM controller
    By Dariolo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th May 2009, 20:33
  4. Replies: 2
    Last Post: - 14th July 2008, 22:11
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44

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