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.
Dependencies: mbed C12832 MMA7660
EMB_Lab2.cpp
00001 // IT Tralee Mechatronics: Embedded Systems Lab#2 00002 00003 #include "mbed.h" 00004 #include "MMA7660.h" 00005 #include "C12832_lcd.h" 00006 00007 MMA7660 MMA(p28, p27); 00008 C12832_LCD lcd; 00009 00010 float calculateAngle(float x, float y, float z) 00011 { 00012 float Angle = 0; 00013 float pi = 3.14159265; // declare pi 00014 Angle = (atan(y/(sqrt((x*x)+(z*z)))))*(180/pi); 00015 return Angle; 00016 } 00017 00018 int main() { 00019 while(1) 00020 { 00021 float Angle = 0; 00022 Angle = (calculateAngle(MMA.x(),MMA.y(),MMA.z())); 00023 lcd.cls(); 00024 lcd.locate(0,0); 00025 lcd.printf("Angles :) \n \r"); 00026 lcd.locate(0,8); 00027 lcd.printf("Angle = %.2f \n \r", Angle); // print angle reading 00028 wait(1); 00029 } 00030 }
Generated on Wed Jul 20 2022 15:52:40 by
