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.
Dependencies: mbed SDFileSystem
Diff: main.cpp
- Revision:
- 3:07afde41e7e6
- Parent:
- 2:81f364f7a4a6
- Child:
- 4:d414aee7ce9d
--- a/main.cpp Fri Apr 19 13:29:31 2019 +0000
+++ b/main.cpp Sun Apr 21 11:32:02 2019 +0000
@@ -13,27 +13,41 @@
DigitalIn butCh(p29);
DigitalIn butMode(p22);
-// LED Outputs Temporarily
-DigitalOut ledC(p28);
-DigitalOut ledD(p27);
-DigitalOut ledE(p26);
-DigitalOut ledF(p25);
-DigitalOut ledG(p24);
-DigitalOut ledH(p25);
+// For music
+PwmOut speaker(p21);
-PwmOut speaker(p21);
+// I2C to drive LED srips
+I2C i2c(p9, p10);
+
+// LED for tests
+DigitalOut testLED(LED1);
/////////////////////////////////////////////////////////
-// Global Variables
+// Variables
bool switchPressed;
bool notePressed;
int prevNote;
int mode;
-int numModes = 2;
+int numModes;
+bool needNote;
+const int addr = 0b0100000 << 1;
+char cmd[2];
////////////////////////////////////////////////////////
+void variableInit() {
+ // modes
+ mode = 0;
+ numModes = 2;
+ switchPressed = false;
+ // keys
+ notePressed = false;
+ prevNote = -1;
+ // wack-a-mole
+ needNote = true;
+}
+
void buttonSetup() {
butC.mode(PullUp);
butD.mode(PullUp);
@@ -118,7 +132,7 @@
}
void switchModeCheck() {
- if (butMode == 1) {
+ if (butMode == 0) {
if (!switchPressed) {
switchPressed = true;
mode++;
@@ -158,15 +172,16 @@
}
int main() {
+ variableInit();
buttonSetup();
- switchPressed = false;
- notePressed = false;
- mode = 0;
- bool needNote = true;
- prevNote = -1;
-
while(1) {
- pressKey();
+ switchModeCheck();
+
+ if (mode == 0) {
+ pressKey();
+ } else if (mode == 1) {
+ cycleSound();
+ }
}
}
\ No newline at end of file
