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 C12832 LM75B
Revision 10:0a026582486a, committed 2021-12-14
- Comitter:
- durham1u
- Date:
- Tue Dec 14 13:18:50 2021 +0000
- Parent:
- 9:f85504b3c707
- Commit message:
- r
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jun 08 10:36:09 2016 +0000
+++ b/main.cpp Tue Dec 14 13:18:50 2021 +0000
@@ -2,9 +2,18 @@
#include "LM75B.h"
#include "C12832.h"
-// Using Arduino pin notation
-C12832 lcd(D11, D13, D12, D7, D10);
-LM75B sensor(D14,D15);
+C12832 lcd(p5, p7, p6, p8, p11);
+LM75B sensor(p28, p27);
+PwmOut speaker(p26);
+float T;
+
+void play_tone(float frequency, float volume, int interval, int rest) {
+ speaker.period(1.0 / frequency);
+ speaker = volume;
+ wait(interval);
+ speaker = 0.0;
+ wait(rest);
+}
int main ()
{
@@ -12,6 +21,19 @@
lcd.cls();
lcd.locate(0,3);
lcd.printf("Temp = %.1f\n", sensor.temp());
- wait(1.0);
- }
+ T = sensor.temp();
+ wait(0.5);
+ if (T>26.5 && T< 26.5+1)
+ {
+ play_tone(250, 0.5, 1, 0);
+ }
+ else if (T>26.5+1 && T< 26.5+2)
+ {
+ play_tone(500, 0.5, 1, 0);
+ }
+ else if (T>26.5+2 && T< 26.5+3)
+ {
+ play_tone(1000, 0.5, 1, 0);
+ }
}
+}