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 Arch_GPIO_Ex1 by
Diff: main.cpp
- Revision:
- 1:36d047c1f0f4
- Parent:
- 0:ed40790a022a
diff -r ed40790a022a -r 36d047c1f0f4 main.cpp
--- a/main.cpp Thu Sep 05 02:19:37 2013 +0000
+++ b/main.cpp Wed Nov 20 01:11:00 2013 +0000
@@ -1,15 +1,24 @@
#include "mbed.h"
+#include "LSM303DLH.h"
-/* Configure a GPIO pin as output for controlling a LED. 'led' is user assigned name and
- 'LED1' is a internal name given to a port pin P1_8 in this Arch platform. */
-DigitalOut led(LED1);
+//DigitalOut led(LED1);
+Serial bbb(P1_13,P1_14); //seeedarch pin for the UART communication tx, rx
+LSM303DLH compass(P0_5, P0_4); //seeedarch pin for I2c communication SDA and SCL
+
+//PwmOut servo(P1_24); //seeedarch pin for the multiturn servo
int main()
{
- while(1) {
- led = 1; // Switch ON the LED.
- wait(0.5); // Wait for 0.5 Seconds.
- led = 0; // Switch OFF the LED.
- wait(0.5); // Wait for 0.5 Seconds.
+ bbb.baud(9600);
+
+ while(1)
+ {
+ if(compass.read())
+ {
+ bbb.printf("ACC:%f %f %f, MAG:%f %f %f\n\r",compass.ax, compass.ay, compass.az, compass.mx, compass.my, compass.mz);
+ bbb.printf("Direction = %.0f\n\r", compass.getHeading() * 180 / 3.14159265358979);
+ wait(0.5);
+ }
}
+
}
