Circuit Diagram:
Note: Connect a 47K ohm resistor between the RST pin and VCC (3.3V)
Vcc for MSP = 3.3V and Vcc for LCD = 5V
LCD used is JHD162A
Circuit Diagram |
Software Code:
The lcd.h can be accessed here: https://binabhatt.blogspot.com/2018/05/pulse-rate-detector-using-msp430.html
#include <msp430.h>
#include "lcd"
/*
* main.c
*/
void int_char();
int j=0;
char str[4];
int temp = 0;
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1OUT=0x00; //Configure Port1 for LCD
P1DIR |= (BIT0 + BIT6); // P1.0 output
InitializeLcm();
ClearLcmScreen();
PrintStr("Temp is");
ADC10CTL0 = SREF_1 + REFON + ADC10ON + ADC10SHT_3 + ADC10IE;
ADC10CTL1 = INCH_10 + ADC10DIV_3;
ADC10CTL0 |= ENC + ADC10SC; //Start Conversion
__bis_SR_register(LPM0_bits + GIE);
temp = ADC10MEM;
temp = ((temp * 27069L - 18169625L)>>16); //temperature in degree celsius
j=temp;
int_char();
LcmSetCursorPosition(2,0);
PrintStr(str);
return 0;
}
//Interrupt vector ADC10
#pragma vector = ADC10_VECTOR
__interrupt void adc_interrupt(void)
{
__bic_SR_register_on_exit(CPUOFF); // Return to active mode
}
//Convert int to char for LCD
void int_char()
{
int s;
s=j%10;
str[2]=(char)(s+48);
j=j/10;
s=j%10;
str[1]=(char)(s+48);
j=j/10;
s=j%10;
str[0]=(char)(s+48);
str[3]='\0';
}
Video Explanation:
No comments:
Post a Comment