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.
Fork of SC_accelerometer by
Revision 1:2d5e4ef32912, committed 2015-09-01
- Comitter:
- gcorderop
- Date:
- Tue Sep 01 05:26:51 2015 +0000
- Parent:
- 0:85760bc5df57
- Child:
- 2:31492faba62d
- Commit message:
- Aqui va el c?digo para leer el aceler?metro y abajo comentado est? el c?digo para la recepci?n de datos en Matlab
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Tue Sep 01 05:26:51 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
--- a/main.cpp Tue Sep 01 00:23:15 2015 +0000
+++ b/main.cpp Tue Sep 01 05:26:51 2015 +0000
@@ -1,1 +1,57 @@
-ada
\ No newline at end of file
+#include "mbed.h"
+#include "MMA8451Q.h"
+Serial pc(USBTX, USBRX);
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+int main(void) {
+ pc.baud(115200);
+
+ MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+ PwmOut rled(LED_RED);
+ PwmOut gled(LED_GREEN);
+ PwmOut bled(LED_BLUE);
+
+ while (true) {
+ rled = 1.0 - abs(acc.getAccX());
+ gled = 1.0 - abs(acc.getAccY());
+ bled = 1.0 - abs(acc.getAccZ());
+ wait(0.2);
+
+ pc.printf("%.2f \r\n ",acc.getAccX());
+// pc.printf("eje y = %.2f \n\r ",acc.getAccY());
+// pc.printf("eje z = %.2f \n\n\r",acc.getAccZ());
+ }
+}
+
+/**********Código de Matlab para leer la señal del acelerometro**************/
+/*
+clear all;
+close all;
+clc;
+%% ======================== ACELEROMETRO =============================== %%
+display('Start');
+
+delete(instrfind);
+pause(0.1);
+mbed = serial('COM5');
+set(mbed,'BaudRate',115200,'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none','Terminator','CR/LF');
+fopen(mbed);
+
+for i = 1 : 20
+ A = fscanf(mbed,'%f');
+ y(1,i)=int8(A*100);
+ pause(0.1);
+end
+
+plot(y);
+axis ([0 i -200 200]);
+xlabel('time')
+ylabel('Voltage')
+
+fclose(mbed);
+delete(mbed);
+clear mbed;
+
+display('End');
+*/
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Sep 01 05:26:51 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c \ No newline at end of file
