A variable interval LED pulser??


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default A variable interval LED pulser??

    I need to pulse an LED (on for ~1 sec) at a variable interval from 1 sec to 3 minutes, as externally controlled by the user. I presume there is some way to use a potentiometer as a peripheral to an ADC input as a means of varying the interval between the output pulses to the LED, but not sure how to do this with the ADC input circuit or the required PICBASIC. Any ideas or examples would be appreciated!

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    You can connect one side of a pot to ground, the other side to +5v and the middle pin to an ADC pin. Then, take a look in the PBP manual under ADCIN - it will tell you how to read the value. If you are unsure what values to use in the defines, use PicMultiCalc (search this forum for it, if you dont have it).

    Once you have ADC working, you can use PicMultiCalc again to work out the timer values to create a 1Hz timer. A simple counter within the timer interrupt will let you flash the led every second, every 2 seconds, or every what every number of seconds you want. Set the target of the counter based on the ADC result.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default

    Couldn't you also do it without timer interrupts? Something like this perhaps (please excuse the C code)?
    Code:
    while(1)
    {
      period = adcin(3);             // read pot'
      period = period / 10 + 1;      // scale to 1..103 (seconds)
      count = 1;                     // start new period
      while(period < count)          //
      { delay_ms(1000);              // delay 1 second
        count++;                     // bump count var'
      }
      led = 1;                       // turn on led
      delay_us(500)                  // for 1/2 second
      led = 0;                       // and off
      delay_us(500)                  // for 1/2 second
    }
    You could use a circuit as simple as the "Spinning Class Strobe" (below) but you would need to change the potentiometer scale to represent a Period of 1 to 103 seconds.

    Regards, Mike
    Attached Images Attached Images  
    Last edited by Mike, K8LH; - 8th August 2010 at 15:15.

  4. #4
    mtrawczy's Avatar
    mtrawczy Guest


    Did you find this post helpful? Yes | No

    Default Mac is that you?

    Mac is that you? it mark from inacomp

  5. #5
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mtrawczy View Post
    Mac is that you? it mark from inacomp
    Whoa! Blast from the past! Hi Mark... You got PM turned on?

    Regards, Mike McLaren, K8LH

Members who have read this thread : 1

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