Colin Johnson's Kent University Lecture 2 Demo 2
Dependencies: MMA7660 USBDevice mbed
Fork of USBKeyboard_HelloWorld by
main.cpp
- Committer:
- colingj
- Date:
- 2015-10-28
- Revision:
- 7:23de08e003ec
- Parent:
- 5:03a4211d593a
File content as of revision 7:23de08e003ec:
#include "mbed.h" #include "USBKeyboard.h" #include "MMA7660.h" /* for the accelerometer */ USBKeyboard keyboard; MMA7660 MMA(D14, D15); /* accelerometer */ int main(void) { float x,y,countdown; countdown = 0.0; while (1) { x = MMA.x(); y = MMA.y(); if (y>0.6f) { keyboard.mediaControl(KEY_VOLUME_DOWN); } if (y<-0.6f) { keyboard.mediaControl(KEY_VOLUME_UP); } if ((abs(x)>0.6f)&&(countdown<=0.0f)) { keyboard.mediaControl(KEY_PLAY_PAUSE); countdown = 10.0f; } countdown -= 1.0f; wait (0.1); } }