Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Q2.cpp
- Revision:
- 0:921dabe69921
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Q2.cpp Sun Nov 18 14:16:59 2018 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "C12832.h"
+
+C12832 lcd(p5, p7, p6, p8, p11);
+const int adresse = 0x98;
+ char octet_config[2];
+ char octet_XOUT[1];
+ char octet_lecture[3];
+ int Ax,Ay,Az;
+ float X,Y,Z;
+
+I2C ansarnia(p28,p27);
+
+int main() {
+ lcd.cls();
+ lcd.locate(0,3);
+ octet_config[0] = 0x07;
+ octet_config[1] = 0x01;
+ octet_XOUT[0] = 0x00;
+
+ ansarnia.write(adresse,octet_config,2);
+ while(true) {
+ ansarnia.write(adresse,octet_XOUT,1);
+ ansarnia.read(adresse,octet_lecture,3);
+ Ax=octet_lecture[0];
+ Ay=octet_lecture[1];
+ Az=octet_lecture[2];
+ if (Ax>32) {
+ X = (Ax-64)*0.046;
+ }
+ else{
+ X = Ax*0.046;
+ }
+ if (Ay>32) {
+ Y = (Ay - 64)*0.046;
+ }
+ else{
+ Y = Ay * 0.046;
+ }
+ if (Az>32) {
+ Z = (Az - 64)*0.046;
+ }
+ else {
+ Z = Az*0.046;
+ }
+ lcd.cls();
+ lcd.locate(0,3);
+ lcd.printf("Ax,%f\n\r",X);
+ wait(0.5);
+ }
+}