Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18f using buttons C codeing HELP!!

Status
Not open for further replies.

Dinnin

New Member
I been reading through the data sheet and can't think of a way to code what i want done or if what i want to do will work, here is what i got.

So i have a simple button setup, and set the RB1 bin as input. When i power on the device i want the screen to read "XXXXXXXXXX" until the button is pressed 1 twice 3 times does not matter once its pressed at least once for the rest of the time i want to screen to read "YYYYYYYYYYYYYYY"

Code:
#define B11 PORTBbits.RB1  // Buttons one

void main ( void ){

         While (B11==1) {
           LCD CODE HERE DISPLAY "XXXXXXXXXXX"
          }

          If (B11==0) {
             LCD CODE HERE DISPLAY "YYYYYYYYYYYYY"
            {
{

Ok so i know this probably looks bad but i am new to this so please bare with me.

First of all i think the problem is after the button is pressed will it just go back to the orginal XXXXX screen, I need it to read XXXXXX until the button has been pressed once then from THEN on only display the YYYYYYYY any ideas?

Also will this work for reading the buttons? or do i need some kind of interrupt, or some way of constnly reading the pin to see when the button has been pressed? please help any links or example code would be great!!
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top