Menu

portc and 7 always 0

Help
2017-11-30
2017-12-01
  • stan cartwright

    stan cartwright - 2017-11-30

    This code extract to wait for a button on portc.0,1,2 tied low to go high doesn't work but testing buttons if on is fine.
    Masking a port like this works on a pic. Please tell me what I'm doing wrong.

    #chip mega328p, 16
    #include <UNO_mega328p.h >
    #option explicit
    #define left_button portc.0 ;cannon buttons
    #define right_button portc.1
    #define fire_button portc.2
    dir left_button in
    dir right_button in
    dir fire_button in
    ;
    do
    temp=(portc and 7) ;ALWAYS ZERO
    glcdprint 0,32,temp
    ;  Randomize
    loop until (portc and 7)>0 ;HELP
    
     
    • Anobium

      Anobium - 2017-12-01

      I remember updating the Help page for you. See http://gcbasic.sourceforge.net/help/_inputs_outputs.html

       
  • stan cartwright

    stan cartwright - 2017-12-01

    avr sometimes use pinc

    do
    randomise
    loop until (pinc and 7)>0
    

    yet, if portc.1=1 then...works ok
    pin is not in include <uno_mega328p.h></uno_mega328p.h>

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.