This program displays x and y axis value on LCD
Dependencies: C12832 MMA7660 mbed
main.cpp@1:d78fabd1905d, 2015-10-10 (annotated)
- Committer:
- dwijaybane
- Date:
- Sat Oct 10 07:09:20 2015 +0000
- Revision:
- 1:d78fabd1905d
- Parent:
- 0:2cb49169252d
comments updated
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dwijaybane | 1:d78fabd1905d | 1 | #include "mbed.h" // Basic Library required for onchip peripherals |
dwijaybane | 1:d78fabd1905d | 2 | #include "MMA7660.h" // Library for MMA7660 3-axis accelerometer |
dwijaybane | 1:d78fabd1905d | 3 | #include "C12832.h" // Library for SPI based LCD |
dwijaybane | 0:2cb49169252d | 4 | |
dwijaybane | 1:d78fabd1905d | 5 | /* Create Objects */ |
dwijaybane | 1:d78fabd1905d | 6 | C12832 lcd(p5, p7, p6, p8, p11); // Initialize lcd object with SPI pins |
dwijaybane | 1:d78fabd1905d | 7 | MMA7660 MMA(p28, p27); // Initialize I2C pins for MMA object |
dwijaybane | 0:2cb49169252d | 8 | |
dwijaybane | 1:d78fabd1905d | 9 | /* Main Program */ |
dwijaybane | 0:2cb49169252d | 10 | int main() { |
dwijaybane | 1:d78fabd1905d | 11 | lcd.cls(); // Clear LCD Screen |
dwijaybane | 1:d78fabd1905d | 12 | lcd.locate(0,3); // Start from x=0 and y=3 pixels |
dwijaybane | 1:d78fabd1905d | 13 | lcd.printf("Accelerometer Value:"); // Display Accelerometer msg on LCD |
dwijaybane | 0:2cb49169252d | 14 | |
dwijaybane | 0:2cb49169252d | 15 | while(1) { |
dwijaybane | 1:d78fabd1905d | 16 | lcd.locate(0,15); // Start from x=0 and y=15 pixels |
dwijaybane | 1:d78fabd1905d | 17 | lcd.printf("x=%5.4f y=%5.4f",MMA.x(),MMA.y()); // Print x and y values max will be 1 |
dwijaybane | 1:d78fabd1905d | 18 | wait(0.1); // 1 sec delay |
dwijaybane | 0:2cb49169252d | 19 | } |
dwijaybane | 0:2cb49169252d | 20 | } |