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: C12832 LM75B MMA7660 mbed
Revision 2:a9c2014f9bd5, committed 2015-03-30
- Comitter:
- CBMalloch
- Date:
- Mon Mar 30 12:28:02 2015 +0000
- Parent:
- 1:189f0ee0223e
- Commit message:
- Exercises most capabilities of the application shield
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832.lib Mon Mar 30 12:28:02 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/askksa12543/code/C12832/#990d5eec2ef6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LM75B.lib Mon Mar 30 12:28:02 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/chris/code/LM75B/#6a70c9303bbe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA7660.lib Mon Mar 30 12:28:02 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/Sissors/code/MMA7660/#36a163511e34
--- a/main.cpp Mon Feb 17 22:12:58 2014 +0000
+++ b/main.cpp Mon Mar 30 12:28:02 2015 +0000
@@ -1,17 +1,56 @@
#include "mbed.h"
+#include "C12832.h"
+#include "MMA7660.h"
+#include "LM75B.h"
+
+PwmOut red(D5);
+PwmOut blue(D8);
+PwmOut green(D9);
-DigitalOut red(D5);
-DigitalOut blue(D8);
-DigitalOut green(D9);
int i;
+C12832 lcd ( D11, D13, D12, D7, D10 );
+// testing using PB9 instead of D14: yields "undefined identifier"
+MMA7660 MMA ( D14, D15 ); // SDA, SCL (defs stolen from temp sensor demo)
+LM75B thermometer ( D14, D15 );
+
+AnalogIn pot1 (A0);
+AnalogIn pot2 (A1);
+
+PwmOut spkr(D6);
+
int main() {
- while(1) {
- for (i=1; i<7; i++) {
- red = i & 1;
- blue = i & 2;
- green = i & 4;
- wait(0.2);
- }
+ float temperature;
+ float frequency;
+ float lnSemitone = log ( 2.0 ) / 12.0f;
+
+ while ( 1 ) {
+ // for (i=0; i<8; i++) {
+ // red = 1.0 - double ( pot1 );
+ // blue = i & 2;
+ // green = i & 4;
+ // }
+
+ red = MMA.x() * 0.5f + 0.5f;
+ green = MMA.y() * 0.5f + 0.5f;
+ blue = float ( pot1 );
+
+ lcd.cls();
+ lcd.locate ( 1, 1 );
+ lcd.printf ( "%5.3f %5.3f %5.3f", MMA.x(), MMA.y(), MMA.z() );
+
+ lcd.locate ( 1, 10 );
+ temperature = thermometer.read();
+ lcd.printf ( "%6.4f degC", temperature );
+
+ int pitch = ( ( ( temperature - 21.5f ) * 8.0f ) );
+ frequency = exp ( lnSemitone * pitch ) * 440.0f;
+ lcd.locate ( 1, 20 );
+ lcd.printf ( "p: %3d; f: %6.2f", pitch, frequency );
+ spkr.period ( 1.0f / frequency );
+ spkr = pot2; // volume, presumably
+
+ wait ( 0.1 );
+
}
}
--- a/mbed.bld Mon Feb 17 22:12:58 2014 +0000 +++ b/mbed.bld Mon Mar 30 12:28:02 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/ \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0 \ No newline at end of file