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.
Revision 0:dc6b1f4adb5a, committed 2018-06-17
- Comitter:
- rakeshravula
- Date:
- Sun Jun 17 08:27:19 2018 +0000
- Child:
- 1:3cded0feb65d
- Commit message:
- -blinking using push button; -motion sensor and sending data to uart(not working yet)
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LIS3DSH.lib Sun Jun 17 08:27:19 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/grantphillips/code/LIS3DSH/#e6a312714223
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Jun 17 08:27:19 2018 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+#include "LIS3DSH.h"
+
+DigitalOut myledG(PD_12);
+DigitalOut myledO(PD_13);
+DigitalOut myledR(PD_14);
+DigitalOut myledB(PD_15);
+InterruptIn button(PA_0);
+Serial uart(PC_6,PC_7);
+ LIS3DSH acc(PA_7, PA_6, PA_5, PE_3);
+
+char buttondetect = 0;
+void buttonIsr()
+{
+ buttondetect = 1;
+ }
+int main() {
+ uart.baud(9600);
+
+ button.fall(&buttonIsr);
+
+ int16_t X, Y, Z; //signed integer variables for raw X,Y,Z values
+ float roll, pitch; //float variables for angles
+
+ if(acc.Detect() != 1) {
+ uart.printf("LIS3DSH Acceleromoter not detected!\n");
+ while(1){ };
+ }
+ while(1) {
+ wait(0.5);
+ static char counter = 0;
+ acc.ReadData(&X, &Y, &Z); //read X, Y, Z values
+ acc.ReadAngles(&roll, &pitch); //read roll and pitch angles
+ uart.printf("X: %d Y: %d Z: %d\n", X, Y, Z);
+ uart.printf("Roll: %f Pitch: %f\n", roll, pitch);
+
+ if(buttondetect){
+ buttondetect = 0;
+ switch(counter){
+ case 0:
+ myledG = !myledG;
+ break;
+ case 1:
+ myledO = !myledO;
+ break;
+ case 2:
+ myledR = !myledR;
+ break;
+ case 3:
+ myledB = !myledB;
+ break;
+ }
+
+ counter++;
+ if(counter >= 4)
+ counter =0;
+
+ // wait(0.5);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Jun 17 08:27:19 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee \ No newline at end of file