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.
main.cpp
00001 #include "mbed.h" 00002 #include "USBMouse.h" 00003 #include "ADXL345.h" 00004 00005 Serial pc(USBTX, USBRX); 00006 00007 USBMouse mouse; 00008 ADXL345 acc(p5, p6, p7, p8); 00009 AnalogIn strength(p15); 00010 00011 00012 int main() { 00013 uint16_t str = 0; 00014 int readings[3]; 00015 00016 //Initialize accelerometer 00017 acc.setPowerControl(0x00); 00018 acc.setDataFormatControl(0x0B); 00019 acc.setDataRate(ADXL345_3200HZ); 00020 acc.setPowerControl(0x08); 00021 00022 while (1) { 00023 wait(0.1); 00024 00025 // test accelerometer 00026 acc.getOutput(readings); 00027 pc.printf("acc: %i, %i, %i\r\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]); 00028 00029 // test strtch sensor 00030 str = strength.read_u16(); 00031 pc.printf("strength: %d\r\n", str); 00032 00033 // test USB relative mouse 00034 mouse.move(10, 10); 00035 } 00036 }
Generated on Fri Jul 15 2022 01:35:31 by
1.7.2