Newbie question about switch + led


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default

    I don't know what MCU chip you are using but if it has and A/D capability PORT A starts up in Analog mode. If this is the case you can fix the problem by:

    1. Avoiding PORTA or

    2. Looking up the A/D info in the MCU spec. This is often in the ADCON1 register and PORTA made digital by putting something like

    ADCON1 = %00001111

    near the beginning of your code. Good luck

    Regards Bill Legge

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bill Legge View Post
    I don't know what MCU chip you are using but if it has and A/D capability PORT A starts up in Analog mode. If this is the case you can fix the problem by:
    The MCU should be a 16F690 ans A3 doubles as MCLR.

    BTW.
    How are the configs set ?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2009
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    Yes correct the MCU is 16F690.
    On the JP5 it is nothing there, just two "soldering holes".

    I don't have a "config set"? The posted code is completely everything i have wrote.

    Maybe i should try to use some other extern components on a breadboard.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This is what I will bet is happening.

    If you have not changed the *.inc file (configs) MCLR is on.

    When A3 = 0 causes the LED to go high, then when the switch is pressed A3 goes to a hard LOW resetting the PIC. Something like that.

    Yup, move over to a bread board to get started.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jan 2009
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    Nah i haven't change anything in the *.inc files.
    I will try with some resistors, switch and led on a breadboard, will get back here when i have tried.
    But so far your eye can see, it isn't anything wrong with the code?
    This is my first real program to PBP, but you get my final point what the program should do right?
    Led = off and when switch is pressed led = on, when switch released led = off.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mradde View Post
    Nah i haven't change anything in the *.inc files.
    I will try with some resistors, switch and led on a breadboard, will get back here when i have tried.
    But so far your eye can see, it isn't anything wrong with the code?
    This is my first real program to PBP, but you get my final point what the program should do right?
    Led = off and when switch is pressed led = on, when switch released led = off.
    Looks "OK" to me.
    Dave
    Always wear safety glasses while programming.

  7. #7
    biggej's Avatar
    biggej Guest


    Did you find this post helpful? Yes | No

    Default

    The PicKit2 has excellent tutorials. Yes they start with assembler but they will teach you the hardware of the LowPin count board if you read the tutorial. They don't take too long to complete either.

    The advice given by MACKRACKIT is right on target. You must change the .inc file to turn mclr off or the pushbutton will reset the PIC. This is explained in the PicBasicPro example code very well.

    Keep trying. The PicKit and LPC are good learning tools.

    Jim

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 04:59
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 14:30
  5. Greetings from Newbie and a question
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th July 2006, 15:52

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