Some help needed (newb content)


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2009
    Posts
    2

    Default Some help needed (newb content)

    Hello,

    Ok, I've been programming in Ass for a while, and now have seen the light.
    Simple prog to flash an led if a button is pressed.

    Code follow:
    -----------------------------------------------------------------------------------------------------
    @ DEVICE pic16F819

    @ DEVICE INTRC_OSC_NOCLKOUT

    @ DEVICE CPD_OFF



    Define OSC 8 'Osciallator 8Mhz

    OSCCON=112 'INT OSC 8 MHZ

    ADCON0 = 0

    CCP1CON = %00000000 'Turn comparators off

    Trisa=%00000001 'Sets PortA RA0 and RA1 as ip rest as output.

    CoolHeat Var PORTA.0 'Switch IP High=flash

    RL1 Var PORTA.1 'Relay output









    Start:

    If CoolHeat=0 THen 'button not pressed

    HIGH RL1

    endif



    If Coolheat=1 Then 'button pressed flashes LED

    high rl1

    pause 500

    Low RL1

    Pause 500

    high rl1

    pause 500

    Low RL1

    Pause 500

    Endif



    goto Start



    end

    -------------------------------------------------------------------------------------------------

    The switch is pulled up via 4k7 to Vcc. LED has 330r in series.

    When I power up the led is on as it should be, switch is open.
    When I pull RA.0 high the led *should* flash but does not.

    Any ideas?

    Many thanks.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    May be you forgot one I/O config line ...

    ADCON1 i.e.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Sep 2009
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    All sorted,

    loose power connection to PIC plus added the code detailed.

    Full steam ahead now!

  4. #4
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Need to also set RA1 as input

    Quote Originally Posted by Woogle View Post
    Trisa=%00000001 'Sets PortA RA0 and RA1 as ip rest as output.
    Your Trisa statement only sets RA0 as in input. Your comment says you want to also set RA1 as input. Therefore you need TRISA = %00000011 .

Similar Threads

  1. ASCII Viewer Needed
    By sougata in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th January 2008, 05:29
  2. Programers Needed Still !
    By picawiner in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th June 2007, 13:51
  3. Newbee Hardware PWM clarification needed
    By emmett brown in forum General
    Replies: 3
    Last Post: - 9th July 2006, 09:18
  4. Circuit needed to allow a PIC to turn something on or off
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th October 2005, 21:17

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