Lee Nam Cheol
/
lab05-app-shield-3-axis
lab05-app-shield
Diff: main.cpp
- Revision:
- 1:e787321cd424
- Parent:
- 0:f31836d48420
diff -r f31836d48420 -r e787321cd424 main.cpp --- a/main.cpp Sun Mar 29 19:41:28 2020 +0000 +++ b/main.cpp Mon May 11 13:03:10 2020 +0000 @@ -1,18 +1,18 @@ #include "mbed.h" +#include "C12832.h" +#include "MMA7660.h" -// https://os.mbed.com/docs/mbed-os/v5.15/tools/creating-a-new-program.html - -Serial pc(USBTX, USBRX, 115200); // baud rate 115200 -DigitalOut led(LED1); // led = LED1 +C12832 lcd(D11, D13, D12, D7, D10); //lcd = (MOSI, SCK, RESET, A0, nCS) +MMA7660 MMA(D14, D15); //MMA = (I2C_SDA, I2C_SCL) int main() { - while (true) { - led = 0; - printf("LED1 is ON\r\n"); - thread_sleep_for(500); - led = 1; - printf("LED1 is OFF\r\n"); - thread_sleep_for(500); + lcd.cls(); //clear screen + lcd.locate(0, 6); + lcd.printf("Mbed 3-Axis accelerometer!"); + while(true) { + lcd.locate(0,16); + lcd.printf("x=%.2f y=%.2f z=%.2f", MMA.x(), MMA.y(), MMA.z()); + thread_sleep_for(100); } } \ No newline at end of file