Build upon MMA7660_HelloWorld to pull out x, y, z axes from device and print to LCD on mbed Application Board
Dependencies: C12832_lcd MMA7660 mbed
Fork of MMA7660_HelloWorld by
Here reside bits and pieces of coding that is mostly derivative of the work of others. Mostly extensions and other modifications.
The proprioception board project.
Board design images follow.
main.cpp@2:b0a8d3b7a6dd, 2013-05-06 (annotated)
- Committer:
- chapfohn
- Date:
- Mon May 06 02:10:12 2013 +0000
- Revision:
- 2:b0a8d3b7a6dd
- Parent:
- 1:0a7a84edc8e5
- Child:
- 3:0d76aaff55b8
Axes labelled, separated into columns.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chapfohn | 1:0a7a84edc8e5 | 1 | //Iteration for 3 axis, ... |
Sissors | 0:bd0546063b0a | 2 | |
Sissors | 0:bd0546063b0a | 3 | #include "mbed.h" |
Sissors | 0:bd0546063b0a | 4 | #include "MMA7660.h" |
chapfohn | 1:0a7a84edc8e5 | 5 | #include "C12832_lcd.h" |
Sissors | 0:bd0546063b0a | 6 | |
chapfohn | 1:0a7a84edc8e5 | 7 | C12832_LCD lcd; |
Sissors | 0:bd0546063b0a | 8 | MMA7660 MMA(p28, p27); |
Sissors | 0:bd0546063b0a | 9 | |
chapfohn | 2:b0a8d3b7a6dd | 10 | DigitalOut connectionLed(LED1);//for later debug |
Sissors | 0:bd0546063b0a | 11 | |
Sissors | 0:bd0546063b0a | 12 | int main() { |
Sissors | 0:bd0546063b0a | 13 | if (MMA.testConnection()) |
Sissors | 0:bd0546063b0a | 14 | connectionLed = 1; |
Sissors | 0:bd0546063b0a | 15 | |
Sissors | 0:bd0546063b0a | 16 | while(1) { |
chapfohn | 1:0a7a84edc8e5 | 17 | lcd.cls();//clear LCD for next reading round |
chapfohn | 2:b0a8d3b7a6dd | 18 | lcd.locate(3,3);//first LCD column label |
chapfohn | 2:b0a8d3b7a6dd | 19 | lcd.printf("x-axis | ");//label column |
chapfohn | 2:b0a8d3b7a6dd | 20 | lcd.locate(3,14);//xdata location |
chapfohn | 1:0a7a84edc8e5 | 21 | lcd.printf("%.2f\n",MMA.x());//print x to LCD |
chapfohn | 2:b0a8d3b7a6dd | 22 | lcd.locate(40,3);//second LCD column label |
chapfohn | 2:b0a8d3b7a6dd | 23 | lcd.printf("y-axis | ");//label column |
chapfohn | 2:b0a8d3b7a6dd | 24 | lcd.locate(40,14);//ydata location |
chapfohn | 1:0a7a84edc8e5 | 25 | lcd.printf("%.2f\n",MMA.y());//print y to LCD |
chapfohn | 2:b0a8d3b7a6dd | 26 | lcd.locate(77,3);//initial LCD location |
chapfohn | 2:b0a8d3b7a6dd | 27 | lcd.printf("z-axis");//label column |
chapfohn | 2:b0a8d3b7a6dd | 28 | lcd.locate(77,14);//zdata location |
chapfohn | 1:0a7a84edc8e5 | 29 | lcd.printf("%.2f\n",MMA.z());//print z to LCD |
chapfohn | 1:0a7a84edc8e5 | 30 | wait(0.5);//update after 0.5 s |
Sissors | 0:bd0546063b0a | 31 | } |
Sissors | 0:bd0546063b0a | 32 | |
Sissors | 0:bd0546063b0a | 33 | } |