h

Dependencies:   MMA7660 USBDevice mbed

Fork of lecture2_demo2 by Colin Johnson

Committer:
colingj
Date:
Wed Oct 28 03:32:05 2015 +0000
Revision:
7:23de08e003ec
Parent:
5:03a4211d593a
Child:
8:d79a78d6b922
final for lecture;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 1:291a88a2c151 1 #include "mbed.h"
samux 1:291a88a2c151 2 #include "USBKeyboard.h"
colingj 7:23de08e003ec 3 #include "MMA7660.h" /* for the accelerometer */
colingj 7:23de08e003ec 4
samux 3:8b56768ceca2 5 USBKeyboard keyboard;
colingj 7:23de08e003ec 6 MMA7660 MMA(D14, D15); /* accelerometer */
colingj 7:23de08e003ec 7
colingj 7:23de08e003ec 8 int main(void)
colingj 7:23de08e003ec 9 {
colingj 7:23de08e003ec 10 float x,y,countdown;
colingj 7:23de08e003ec 11 countdown = 0.0;
samux 1:291a88a2c151 12 while (1) {
colingj 7:23de08e003ec 13 x = MMA.x();
colingj 7:23de08e003ec 14 y = MMA.y();
colingj 7:23de08e003ec 15 if (y>0.6f) { keyboard.mediaControl(KEY_VOLUME_DOWN); }
colingj 7:23de08e003ec 16 if (y<-0.6f) { keyboard.mediaControl(KEY_VOLUME_UP); }
colingj 7:23de08e003ec 17 if ((abs(x)>0.6f)&&(countdown<=0.0f)) {
colingj 7:23de08e003ec 18 keyboard.mediaControl(KEY_PLAY_PAUSE);
colingj 7:23de08e003ec 19 countdown = 10.0f;
colingj 7:23de08e003ec 20 }
colingj 7:23de08e003ec 21 countdown -= 1.0f;
colingj 7:23de08e003ec 22 wait (0.1);
samux 1:291a88a2c151 23 }
samux 4:f0df6aae7147 24 }