PARTYYYY

Dependencies:   mbed MMA8452

Files at this revision

API Documentation at this revision

Comitter:
evrast
Date:
Mon Sep 04 19:51:12 2017 +0000
Child:
1:ad54e8b7ac20
Commit message:
App1 partyyyyy

Changed in this revision

Accelerometre.cpp Show annotated file Show diff for this revision Revisions of this file
Accelerometre.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Accelerometre.cpp	Mon Sep 04 19:51:12 2017 +0000
@@ -0,0 +1,20 @@
+#include "Accelerometre.h"
+
+
+
+
+int Accelerometre::readSingleByte(int regis){
+    char cmd[8];
+    int c;
+    pc.printf("Reading single byte\n");  
+    i2c.start();
+    int a=i2c.write(0x38);  // A write to device
+    i2c.write(regis); // Register to read from (acceleration in X)
+    i2c.start();        // Need to send start condition here
+    i2c.write(0x39); // tell devide you want to read
+    c=i2c.read(0);      
+    i2c.stop();
+    pc.printf("value is %d\n", c);
+    pc.printf("end\n");
+    return c;
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Accelerometre.h	Mon Sep 04 19:51:12 2017 +0000
@@ -0,0 +1,9 @@
+#include "mbed.h"
+
+class Accelerometre{
+    
+    int readSingleByte(int regist);
+    
+    
+    }
+    
\ No newline at end of file