Answer to Question #269255 in C for Mr Z

Question #269255

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


1
Expert's answer
2021-11-21T04:51:04-0500
#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);
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS