using a pot to control a time range


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Is that the whole program that you have coded?
    'cause I don't see ANY of the ADC DEFINEs as shown in the PBP manual there, not that they're really needed, but could be helpful.
    Also, are you sure the program is even running? (i.e. blinky LED?)

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Try this. I've used something similar to it on a 12F675 and had no problems. You should be able to turn on the LED for up to 255 seconds (the maximum byte value).

    CMCON = 7 'comparators off
    trisio = %11111111 'ALL INPUTS - HIGH & LOW COMMANDS CONVERT TO OUTPUTS
    DEFINE OSCCAL_1K 1 'Set OSCCAL for 1K device
    POTVALUE VAR BYTE 'POTENTIOMETER VALUE VARIABLE
    LEDTIMER VAR BYTE 'LED TIMER VARIABLE

    START:
    LET LEDTIMER = 0 'RESET TIMER TO 0
    Low GPIO.4 'TURN OFF LED ON GPIO.4
    PAUSE 5000 'STAY OFF FOR AT LEAST 5 SECONDS
    ADCIN 1,POTVALUE 'READ VALUE OF POT
    IF POTVALUE = 0 THEN START 'STAY HERE OFF UNTIL POT IS TURNED

    LEDON:
    High GPIO.4 'TURN ON LED FOR 1 SECOND INCREMENTS
    PAUSE 1000
    LET LEDTIMER = (LEDTIMER + 1) 'COUNT SECONDS
    ADCIN POTVALUE 'READ POT VALUE
    IF POTVALUE > LEDTIMER THEN LEDON 'STAY HERE ON UNTIL LEDTIMER = POTVALUE
    GOTO START 'LEDTIMER = POTVALUE GOTO START & RESET
    Last edited by peterdeco1; - 17th June 2008 at 20:14. Reason: FORGOT LINE

Similar Threads

  1. 16F877 elapsed time control
    By BerkayT in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 12th February 2009, 18:23
  2. servo control via pot ?
    By n0oxv in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 1st March 2007, 08:11
  3. Control unlimited servos at the same time
    By mrx23 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th September 2006, 15:14
  4. Button pressed time control
    By tanero in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 15th August 2005, 16:17
  5. trying the pot command to control delay
    By reddogtj in forum mel PIC BASIC
    Replies: 2
    Last Post: - 20th May 2005, 13:50

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