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: main.cpp
- Revision:
- 1:dc6884f965e1
- Parent:
- 0:e9410807b683
--- a/main.cpp Tue Nov 02 08:13:07 2021 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-#include "mbed.h"
-
-SPI acc(D11, D12, D13);
-DigitalOut cs(D7);
-
-Serial pc(USBTX, USBRX);
-char buffer[6];
-int16_t data[3];
-float x,y,z;
-
-int main(){
- cs=1;
- acc.format(8,3);
- acc.frequency(2000000);
- cs=0;
- acc.write(0x31);
- acc.write(0x0B);
- cs=1;
- cs=0;
- acc.write(0x2D);
- acc.write(0x08);
- cs=1;
- while (1){
- wait(1);
- cs=0;
- acc.write(0x80|0x40|0x32);
- for (int i=0; i<=5; i++){
- buffer[i]=acc.write(0x00);
- }
- cs=1;
- data[0] = buffer[1]<<8 | buffer[0];
- data[1] = buffer[3]<<8 | buffer[2];
- data[2] = buffer[5]<<8 | buffer[4];
- x = 0.004*data[0];
- y = 0.004*data[1];
- z = 0.004*data[2];
-
- pc.printf("ax=%1.2fg\t ay=%1.2fg\t az=%1.2fg\n\r", x, y, z);
- }
-}