C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Motor operation toggle to be shown on LCD Posted by MairtinH2 on 28 May 2012 at 2:24 AM
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:
#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
}



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.