Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

character to LCD and buttons events

$
0
0

Hello,

I'm trying to make a digital clock. Using the MCU MSP430G2553, but I'm having trouble displaying the characters on the LCD. 
 
created a variable as follows: 
unsigned int sec = 00; 
I liked that the LCD aparececem both 0, but only shows one.
 
Another problem is I have 3 switch buttons, one for setup, one for increment and decrement to another, how can I add events to each of the buttons? Initially I set the 3 buttons:
#include <msp430g2553.h>
#include "lcdLib.h"
#define 	SETUP_SWITCH	BIT3;
#define 	BUTTON_UP	BIT6;
#define         BUTTON_DOWN	BIT7;

//initial value of the increment button setup
unsigned int butSetup = 0;

void main(void){
	WDTCTL = WDTPW + WDTHOLD;
 P1DIR &= ~SETUP_SWITCH;
 P1OUT |= SETUP_SWITCH;
 P1REN |= SETUP_SWITCH;
 P1IES |= SETUP_SWITCH;
 P1IFG &= ~SETUP_SWITCH;
 P1IE |= SETUP_SWITCH;

/*other buttons
... 
*/

 __delay_cycles(1000000);

 __enable_interrupt();



lcdInit(); 
lcdSetText("ECG HOLTER",3, 0);
lcdSetText("START:",4, 1);



for(i=9; i>=0 ;i--){

	lcdSetInt(i,11, 1);
	delay_ms(1000);
	if(i==0){
	lcdClear();
	registoData();
}

while(1)
{

  _bis_SR_register(LPM0_bits);
}

}

Now how can I select option for the buttons?

I am thinking about creating a switch case for each of bottoes for example, for each of the data in SWITCH_BUTTON clicks, count the number of clicks data and assign each a switch case.

for example:

switch(butSetup){
case 1:
//code ....
break;
 
case 2:
//code
break;

default:
}

Can anyone help me?

 

 


Viewing all articles
Browse latest Browse all 2077

Trending Articles