1) write a program for the development board that measures gravitational acceleration in 3-axes and displays the values on the LCD screen.
The program will do the following:
a) To be run upon initialization (i.e. implement this in the setup() function)
• Initialize the development board
• Sound the buzzer
• Write the message “ACCELEROMETER” on the LCD screen.
• Wait two seconds
• Sound the buzzer
#include <plib.h>
#include "LCD.h"
#define CLK LATGbits.LATG15
void LCDCHAR(char c);
void LCDcommand(int command, int T7, int T6, int T5, int T4, int T3, int T2, int T1, int T0);
void wait();
void LCDSetup() {
TRISGbits.TRISG12 = 0;
TRISGbits.TRISG15 = 0;
TRISECLR = 0xFF;
LCDcommand(0,0,0,1,1,1,0,0,0);
LCDcommand(0,0,0,0,0,0,0,0,1);
LCDcommand(0,0,0,0,0,0,1,1,0);
LCDcommand(0,0,0,0,0,1,1,0,0);
}
void LCDChar(char C) {
LCDcommand(1, C>>7&1, C>>6&1, C>>5&1, C>>4&1, C>>3&1, C>>2&1, C>>1&1, C&1);
}
void LCDWriteString(char *str, int R, int C) {
R--; C--;
LCDcommand(0,1,R,0,0,C>>3&1,C>>2&1,C>>1&1,C&1);
while(*str) LCDChar(*str++);
}
void LCDClear(int L) {
switch(L) {
case 1:
LCDWriteString(" ", 1, 1);
break;
case 2:
LCDWriteString(" ", 2, 1);
break;
default:
LCDcommand(0,0,0,0,0,0,0,0,1);
}
}
Comments
Leave a comment