problem 2 for HW 2
Dependencies: 4DGL-uLCD-SE 4180_LSM9DS0_lab LSM9DS0 mbed
Fork of 4180_LSM9DS0_lab by
main.cpp
- Committer:
- aswild
- Date:
- 2015-01-26
- Revision:
- 0:29ab304ca8ce
- Child:
- 1:ae1cefe9aa38
File content as of revision 0:29ab304ca8ce:
// LSM9DS90/uLCD Demo // ECE 4180 Lab Code Template #include "mbed.h" #include "LSM9DS0.h" #include "uLCD_4DGL.h" // SDO_XM and SDO_G are pulled up, so our addresses are: #define LSM9DS0_XM_ADDR 0x1D // Would be 0x1E if SDO_XM is LOW #define LSM9DS0_G_ADDR 0x6B // Would be 0x6A if SDO_G is LOW #define REFRESH_TIME_MS 50 // Verify that the pin assignments below match your breadboard LSM9DS0 imu(p9, p10, LSM9DS0_G_ADDR, LSM9DS0_XM_ADDR); uLCD_4DGL lcd(p28, p27, p30); Serial pc(USBTX, USBRX); // tx, rx //Init Serial port and LSM9DS0 chip void setup() { lcd.baudrate(3000000); lcd.background_color(0); lcd.cls(); lcd.printf("Initializing..."); // Use the begin() function to initialize the LSM9DS0 library. // You can either call it with no parameters (the easy way): uint16_t status = imu.begin(); //Make sure communication is working pc.printf("LSM9DS0 WHO_AM_I's returned: 0x%X\n", status); pc.printf("Should be 0x49D4\n\n"); } int main() { setup(); //Setup sensor and Serial pc.printf("------ LSM0DS0 Demo -----------\n"); while (true) { // TODO - add code here to read compass or accelerometer data // and display it on the uLCD // Compass Trigonometry tip: you can retrieve the compass heading (in degrees) directly from // the IMU library. Example: // imu.readMag(); // float heading = imu.calcHeading(); // Remember that x = length*cos(heading) and y = length*sin(heading) // to convert from degrees to radians (for sin/cos functions), multiply by pi/180 wait_ms(REFRESH_TIME_MS); } }