Problem with led


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default Problem with led

    I have conect two leds to porta.2 and porta.3.
    My problem is when i press 1 or 2 keys on keyboard (PC) the led isn't turn on
    My pic is 16f88
    Code:
        old var byte
        new var byte
    
        
    main:
        serout porta.0, T9600, ["Enter which LED to light (0-1): ", 10, 13]
        serin porta.1, T9600, #new
        serout porta.0, T9600, ["LED Chosen: ", #new, 10, 13]
        Pause 100
        low old
        high new
        old = new
    goto main

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


    Did you find this post helpful? Yes | No

    Default

    Hi, Savnik

    LOW and HIGH commands can't be applied to variables ... but Ports or aliases.

    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
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    I have conect two leds to porta.2 and porta.3.
    My problem is when i press 1 or 2 keys on keyboard (PC) the led isn't turn on
    My pic is 16f88
    Code:
        new var byte
        led   var PORTA.2
        led1  var PORTA.3
        
    main:
        serout porta.0, T9600, ["Enter which LED to light (0-1): ", 10, 13]
        serin porta.1, T9600, #new
        serout porta.0, T9600, ["LED Chosen: ", #new, 10, 13]
        Pause 100
        if new = 1 then high led
        if new = 2 then high led1
    goto main
    I change the code and now works , but idon't like this.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    I change the code and now works , but idon't like this.
    What's wrong with it? Short, simple, functional...

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    I see an analog port issue going around.

    It happens to all of us, or does it?


    Also, where do you turn OFF the LEDs?

    Once you set them HIGH, when will they get set LOW?


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

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    I see an analog port issue going around.

    It happens to all of us, or does it?


    Also, where do you turn OFF the LEDs?

    Once you set them HIGH, when will they get set LOW?


    ------------------------------
    new var byte
    led1 var PORTA.2
    led2 var PORTA.3

    adcon.1 = 7

    main:
    new = 0
    serout porta.0, T9600, ["Enter which LED to light (1-2,0=Off): ", 10, 13]
    serin porta.1, T9600, new
    serout porta.0, T9600, ["LED Chosen: ", new, 10, 13]
    if new = "1" then
    high led1 : low led2
    enfif
    if new = "2" then
    high led2 : low led1
    endif
    if new = "0" then
    low led1 : low led2
    endif

    goto main

  7. #7
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    I see an analog port issue going around.

    It happens to all of us, or does it?
    ------------------------------
    I have at the top of code:

    CMCON = 7
    ANSEL = 0


    Quote Originally Posted by sayzer View Post
    Also, where do you turn OFF the LEDs?

    Once you set them HIGH, when will they get set LOW?


    ------------------------------
    This is my problem

  8. #8
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Savnik,

    Take a look at the post before yours.

    skimask has it for you.


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

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. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. Flashing!! LED Dot matrix problem
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th December 2006, 09:45

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