Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Motor operation toggle to be shown on LCD

MairtinH2MairtinH2 Posts: 3Member
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
}[/code]
Sign In or Register to comment.