Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Motor operation toggle to be shown on LCD

MairtinH2MairtinH2 Member Posts: 3
How do you show the motor operation toggle on an LCD (Motor:ON , Motor:OFF). Using an interrupt to toggle motor operation however cannot display the messages properly and cannot figure it out any help would be greatly appreciated.

This is the code so far:
[code]#define Relayswitch RB0 //renames port B0 as But1
#define CounterON RB1 //renames port B1 as But2
#define Reset RB2 //renames port B2 as But3
#define RELAY RA0 //renames port A0 as RELAY

//declare function prototypes
void interrupt ext0_ISR(void);
//end function declares

void main(void)
TRISB=0x0F; //Sets port B as Inputs
TRISA=0x00; //Sets port A as outputs
TRISD=0x00; //Sets port D as Outputs

ADCON1 = 0x06; //ensure port A configured for digital IO

PORTA=0; //Clears Port A
PORTB=0; //Clears Port B
PORTD=0; //Clears Port D

INTE = 1; //RB0 interrupt enable
PEIE = 1; //Peripheral interrupt enable
GIE = 1; //Global interrupt enable
INTEDG = 0; // interrupt on falling edge

init_LCD(); //function to initialise LCD
LCD_function(0x0C); //function to turn LCD on

unsigned char counter; //Stores counter in memory

while (1) //continuous loop

void interrupt ext0_ISR(void)
if (INTF && INTE) //ensure interrupt generated by transition on RB0
delay_ms(10); //delay 10ms for contact bounce elimination
if (Relayswitch == 0) //test if button still pressed
RELAY = RELAY^1; //YES - Toggle motor control
while (!Relayswitch){}; //do nothing while button is still pressed

INTF = 0; //clear interrupt flag
Sign In or Register to comment.