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:
- 0:ea609f08f075
- Child:
- 1:06020d654386
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Aug 08 10:44:11 2020 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"//preprosser demand
+#include "MMA7660.h"//preprocesser demand
+
+#define PI 3.14159265//PI defined
+
+Serial pc(USBTX,USBRX);//serial transmission to pc via USBTX, USBRX
+MMA7660 MMA(p28,p27);//IC2 pins associated with accelerometer
+
+float calculateAngle(float x,float y,float z){
+ float angle = 0;
+// calculate the angle from the formula given in the instructions
+
+angle = (y*y) + (z*z);
+angle = sqrt (angle);
+angle = x/angle;
+angle = atan (angle);
+angle = angle *180/PI; //radians to degrees!
+return angle;
+}
+
+int main(){
+ while (1){
+ pc.printf(" X%f Y%f Z%f angle%.2f degrees\r", MMA.x(),
+ MMA.y(), MMA.z(), calculateAngle(MMA.x(), MMA.y(), MMA.z()));
+
+ wait(1);
+ }
+}