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.
Revision 6:62095a0c2429, committed 2013-06-27
- Comitter:
- chapfohn
- Date:
- Thu Jun 27 05:26:26 2013 +0000
- Parent:
- 5:ba17585f3a2a
- Commit message:
- Takes readings of stability, assigns to score [+1] for each success.
; If ten consecutive readings are stable [score 10] prints 'NEXT LEVEL',
; LED2 HIGH for ten seconds, score assignment reset.
; Any unstable reading resets score assignment.
;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ba17585f3a2a -r 62095a0c2429 main.cpp --- a/main.cpp Wed Jun 05 01:27:07 2013 +0000 +++ b/main.cpp Thu Jun 27 05:26:26 2013 +0000 @@ -14,10 +14,11 @@ C12832_LCD lcd; MMA7660 MMA(p28, p27); -DigitalOut connectionLed(LED1);//for later debug +DigitalOut connectionLed(LED1);//operation confirmed +DigitalOut servoProxyLed(LED2);//score outcome, proxy for servo const int n = 10; //number of readings to be averaged, change globally here -int score = 0; //reserved for later +float score = 0; //reserved for later int angle = 0; //reserved for later float pulseXT =0, pulseYT = 0; //Total holders for summation from axis arrays @@ -63,7 +64,20 @@ lcd.printf("%.2f\n",MMA.z());//print z to LCD lcd.locate(3,21);//flag location lcd.printf("STABLE");//flag - //wait (2); + if (score != 10) {//if score has not reached 10 + ++score;//add 1 to score + lcd.locate(70,21);//score location + lcd.printf("SCORE = "); + lcd.printf("%.0f\n",score);//print score + } else { + servoProxyLed = 1;//LED2 HIGH + lcd.locate(70,21);//notice location + lcd.printf("NEXT LEVEL"); + wait (10); + servoProxyLed = 0;//LED@ LOW + score = 0;//reset score + + } } else {////average result not within stability range; x, y @@ -82,7 +96,11 @@ lcd.printf("%.2f\n",MMA.z());//print z to LCD lcd.locate(3,21);//flag location lcd.printf("UNSTABLE");//flag - //wait (2); + score = 0;//reset score + lcd.locate(70,21);//score location + lcd.printf("SCORE = "); + lcd.printf("%.0f\n",score);//print score + } } } \ No newline at end of file