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: TextLCD mbed MMA8451Q TSI
Diff: main.cpp
- Revision:
- 1:47973f27d645
- Parent:
- 0:f48fccfff709
- Child:
- 2:86de87ec731a
--- a/main.cpp Fri Aug 14 10:35:11 2015 +0000
+++ b/main.cpp Fri Aug 14 13:32:24 2015 +0000
@@ -1,5 +1,6 @@
#include "mbed.h"
#include <Button.cpp>
+#include "TextLCD.h"
#define DO4 262
#define RE4 294
@@ -9,18 +10,35 @@
#define LA4 440
#define SI4 494
+//TextLCD lcd(PTE5, PTE3, PTE2, PTB11, PTB10, PTB9, TextLCD::LCD16x2); //TextLCD (PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type=LCD16x2, PinName bl=NC, PinName e2=NC, LCDCtrl ctrl=HD44780)
Speaker speaker (PTA4);
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
+int freq =0;
+bool activeNotes[7];
int main(){
led1=1;
led2=1;
led3=1;
- Button a (PTA1, LA4, &speaker, &led1);
- Button b (PTA2, DO4, &speaker, &led2);
- Button c (PTA12, FA4, &speaker, &led3);
+ Button a (PTA1, LA4, &activeNotes[5], &led1);
+ Button b (PTA2, DO4, &activeNotes[0], &led2);
+ Button c (PTA12, FA4, &activeNotes[3], &led3);
+ //lcd.cls();
while (true){
+ freq=0;
+ if(activeNotes[0])
+ freq+=FA4;
+ if(activeNotes[3])
+ freq+=DO4;
+ if(activeNotes[5])
+ freq+=LA4;
+ if(freq>0){
+ speaker.PlayNote(freq, 0.005, 0.2);
+ //lcd.printf("%d", freq);
+ //wait(0.1);
+ //lcd.cls();
+ }
}
}
\ No newline at end of file
