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
main.cpp
- Committer:
- kchen7
- Date:
- 2019-04-12
- Revision:
- 0:fa9e77516ba6
- Child:
- 1:b0962a8bcc6d
File content as of revision 0:fa9e77516ba6:
// ESE350 Final Project: Drue
#include "mbed.h"
#include <string>
// Pin setup / variable declarations
DigitalIn butC(p6);
DigitalIn butD(p8);
DigitalIn butE(p10);
DigitalIn butF(p14);
DigitalIn butG(p16);
DigitalOut ledC(p5);
DigitalOut ledD(p7);
DigitalOut ledE(p9);
DigitalOut ledF(p13);
DigitalOut ledG(p15);
DigitalIn butMode(p17);
PwmOut speaker(p26);
bool switchPressed;
int mode;
int numModes = 2;
void switchModeCheck() {
if (butMode == 1) {
if (!switchPressed) {
switchPressed = true;
mode++;
if (mode == numModes) {
mode = 0;
}
}
} else {
switchPressed = false;
}
}
void cycleSound() {
// static int count = 0;
speaker.period(1.0/(500.0 + 100.0));
speaker = 0.5;
wait(0.2);
speaker = 0;
//count++;
//if (count == 8) {count = 0;}
}
int main() {
switchPressed = false;
mode = 0;
while(1) {
switchModeCheck();
if (mode == 0) {
if (butC == 1) {
ledC = 0;
cycleSound();
} else {
ledC = 1;
cycleSound();
}
if (butD == 1) {
ledD = 0;
cycleSound();
} else {
ledD = 1;
}
if (butE == 1) {
ledE = 0;
cycleSound();
} else {
ledE = 1;
}
if (butF == 1) {
ledF = 0;
cycleSound();
} else {
ledF = 1;
}
if (butG == 1) {
ledG = 0;
cycleSound();
} else {
ledG = 1;
}
}
if (mode == 1) {
}
}
}
