This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Help! Trying to set up if statement for inut pin

I have been trying to use this command but only being a novice I am lost. I get error 67 - undefined error. can anyone tell me how to define input pin? thanks

Parents
  • Well, I'm not sure which pin you're after, but if you wanted to check the status of, say, pin 5 of port 3, the you'd write something like this:

    if ( ( P3 & (1 << 5) ) == 1 )
        /* do something here */;
    
    or
    /* declare special bit */
    sbit my_pin = P3 ^ 5;
    ...
    if ( py_pin == 1 )
        /* do something here */;
    
    And judging by the piece of code you presented it looks like you'll have to read up on both the C programming language and the C166 microcontroller family.

    - mike

Reply
  • Well, I'm not sure which pin you're after, but if you wanted to check the status of, say, pin 5 of port 3, the you'd write something like this:

    if ( ( P3 & (1 << 5) ) == 1 )
        /* do something here */;
    
    or
    /* declare special bit */
    sbit my_pin = P3 ^ 5;
    ...
    if ( py_pin == 1 )
        /* do something here */;
    
    And judging by the piece of code you presented it looks like you'll have to read up on both the C programming language and the C166 microcontroller family.

    - mike

Children