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.
Fork of 4_accelerometer by
Revision 1:01baa9666217, committed 2016-05-10
- Comitter:
- maclobski
- Date:
- Tue May 10 03:32:46 2016 +0000
- Parent:
- 0:c482a7d7d833
- Commit message:
- for testing
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon May 09 19:51:02 2016 +0000
+++ b/main.cpp Tue May 10 03:32:46 2016 +0000
@@ -1,14 +1,13 @@
#include "mbed.h" // this tells us to load mbed related functions
#include "tones.h" // list of all the tones and their frequencies
-#include "fxos8700cq/fxos8700cq.h" // library for the accelerometer
+#include "FXOS8700CQ.h" // library for the accelerometer
InterruptIn btn2(SW2); // we create a variable 'btn2', use it as an in port
InterruptIn btn3(SW3); // we create a variable 'btn3', use it as an in port
PwmOut buzzer(D3); // our buzzer is a PWM output (pulse-width modulation)
-AnalogIn pad(A0); // connect a pad to the analog input
-Ticker readTicker;
+Timeout tone_timeout; //TimeOut = a interrupt to call a function after a specified delay
// Set up the accelerometer (this is specific to the onboard one)
InterruptIn accel_interrupt_pin(PTC13);
@@ -25,11 +24,6 @@
buzzer.write(0.10f); // 10% duty cycle, otherwise it's too loud
}
-static bool is_pad_high = false;
-static void read_pad() {
- // YOUR CODE HERE (2)
-}
-
static void play_note1() {
play_tone(NOTE_C4);
}
@@ -37,8 +31,14 @@
play_tone(NOTE_D4);
}
-// YOUR CODE HERE (1)
-
+// YOUR CODE HERE
+//REMOVE
+static void play_note3() {
+ play_tone(NOTE_E4);
+
+ tone_timeout.attach(&silence, 0.2); // setup tone_timeout to call silence after 200 duration ms
+}
+//END REMOVE
// this code runs when the microcontroller starts up
int main() {
// play note when we fall
@@ -57,6 +57,4 @@
accel.config_feature(); // turn on motion detection
accel.enable(); // enable accelerometer
- readTicker.attach(&read_pad, 0.03); // the address of the function to be attached (flip) and the interval (in seconds)
-
}
