3-Axio Digital Gyro

Dependencies:   ITG3200 WebSocketClient WiflyInterface mbed

Files at this revision

API Documentation at this revision

Comitter:
mbedschool
Date:
Fri Feb 06 04:55:02 2015 +0000
Commit message:
gyro

Changed in this revision

ITG3200.lib Show annotated file Show diff for this revision Revisions of this file
WebSocketClient.lib Show annotated file Show diff for this revision Revisions of this file
WiflyInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ITG3200.lib	Fri Feb 06 04:55:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/components/code/ITG3200/#ff0a59c5c2f7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Fri Feb 06 04:55:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#466f90b7849a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WiflyInterface.lib	Fri Feb 06 04:55:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/WiflyInterface/#fb4494783863
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Feb 06 04:55:02 2015 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+#include "WiflyInterface.h"
+#include "Websocket.h"
+#include "ITG3200.h"
+ 
+
+/* wifly interface:
+*     - p9 and p10 are for the serial communication
+*     - p19 is for the reset pin
+*     - p26 is for the connection status
+*     - "mbed" is the ssid of the network
+*     - "password" is the password
+*     - WPA is the security
+*/
+WiflyInterface wifly(p13, p14, p19, p26, "WWNet", "mmmmmmmm", WPA);
+DigitalOut led1(LED1);
+ITG3200 gyro(p9, p10, 0x68);
+
+
+ 
+int main() {
+    wifly.init(); //Use DHCP
+    //wifly.init("192.168.21.33","255.255.255.0","192.168.21.2");
+    while (!wifly.connect());
+    led1=1;
+    printf("IP Address is %s\n\r", wifly.getIPAddress());
+
+    Websocket ws("ws://sockets.mbed.org/ws/mbedschool/viewer");
+    //Websocket ws("ws://192.168.199.159:8888");
+    while (!ws.connect());
+    led1=2;
+ 
+   
+    int x = 0, y = 0, z = 0, temp = 0;
+    //Set highest bandwidth.
+    gyro.setLpBandwidth(LPFBW_42HZ);
+ 
+    while (1) {
+        char data[256];
+        wait(0.1f);
+        x = gyro.getGyroX();
+        y = gyro.getGyroY();
+        z = gyro.getGyroZ();
+        temp = gyro.getTemperature();
+  
+        printf("Temp: %d, X: %d, Y: %d, Z: %d\n", temp, x, y, z);
+        sprintf( data , "Temp: %d, X: %d, Y: %d, Z: %d\n", temp, x, y, z );
+        ws.send(data);
+        
+        //wait(1.0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Feb 06 04:55:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file