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
main.cpp@1:47973f27d645, 2015-08-14 (annotated)
- Committer:
- mfurlanetto
- Date:
- Fri Aug 14 13:32:24 2015 +0000
- Revision:
- 1:47973f27d645
- Parent:
- 0:f48fccfff709
- Child:
- 2:86de87ec731a
funziona, ma non mi piace il codice.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mfurlanetto | 0:f48fccfff709 | 1 | #include "mbed.h" |
| mfurlanetto | 0:f48fccfff709 | 2 | #include <Button.cpp> |
| mfurlanetto | 1:47973f27d645 | 3 | #include "TextLCD.h" |
| mfurlanetto | 0:f48fccfff709 | 4 | |
| mfurlanetto | 0:f48fccfff709 | 5 | #define DO4 262 |
| mfurlanetto | 0:f48fccfff709 | 6 | #define RE4 294 |
| mfurlanetto | 0:f48fccfff709 | 7 | #define MI4 330 |
| mfurlanetto | 0:f48fccfff709 | 8 | #define FA4 349 |
| mfurlanetto | 0:f48fccfff709 | 9 | #define SOL4 392 |
| mfurlanetto | 0:f48fccfff709 | 10 | #define LA4 440 |
| mfurlanetto | 0:f48fccfff709 | 11 | #define SI4 494 |
| mfurlanetto | 0:f48fccfff709 | 12 | |
| mfurlanetto | 1:47973f27d645 | 13 | //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) |
| mfurlanetto | 0:f48fccfff709 | 14 | Speaker speaker (PTA4); |
| mfurlanetto | 0:f48fccfff709 | 15 | DigitalOut led1(LED1); |
| mfurlanetto | 0:f48fccfff709 | 16 | DigitalOut led2(LED2); |
| mfurlanetto | 0:f48fccfff709 | 17 | DigitalOut led3(LED3); |
| mfurlanetto | 1:47973f27d645 | 18 | int freq =0; |
| mfurlanetto | 1:47973f27d645 | 19 | bool activeNotes[7]; |
| mfurlanetto | 0:f48fccfff709 | 20 | |
| mfurlanetto | 0:f48fccfff709 | 21 | int main(){ |
| mfurlanetto | 0:f48fccfff709 | 22 | led1=1; |
| mfurlanetto | 0:f48fccfff709 | 23 | led2=1; |
| mfurlanetto | 0:f48fccfff709 | 24 | led3=1; |
| mfurlanetto | 1:47973f27d645 | 25 | Button a (PTA1, LA4, &activeNotes[5], &led1); |
| mfurlanetto | 1:47973f27d645 | 26 | Button b (PTA2, DO4, &activeNotes[0], &led2); |
| mfurlanetto | 1:47973f27d645 | 27 | Button c (PTA12, FA4, &activeNotes[3], &led3); |
| mfurlanetto | 1:47973f27d645 | 28 | //lcd.cls(); |
| mfurlanetto | 0:f48fccfff709 | 29 | while (true){ |
| mfurlanetto | 1:47973f27d645 | 30 | freq=0; |
| mfurlanetto | 1:47973f27d645 | 31 | if(activeNotes[0]) |
| mfurlanetto | 1:47973f27d645 | 32 | freq+=FA4; |
| mfurlanetto | 1:47973f27d645 | 33 | if(activeNotes[3]) |
| mfurlanetto | 1:47973f27d645 | 34 | freq+=DO4; |
| mfurlanetto | 1:47973f27d645 | 35 | if(activeNotes[5]) |
| mfurlanetto | 1:47973f27d645 | 36 | freq+=LA4; |
| mfurlanetto | 1:47973f27d645 | 37 | if(freq>0){ |
| mfurlanetto | 1:47973f27d645 | 38 | speaker.PlayNote(freq, 0.005, 0.2); |
| mfurlanetto | 1:47973f27d645 | 39 | //lcd.printf("%d", freq); |
| mfurlanetto | 1:47973f27d645 | 40 | //wait(0.1); |
| mfurlanetto | 1:47973f27d645 | 41 | //lcd.cls(); |
| mfurlanetto | 1:47973f27d645 | 42 | } |
| mfurlanetto | 0:f48fccfff709 | 43 | } |
| mfurlanetto | 0:f48fccfff709 | 44 | } |
