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: Map
Revision 1:0e180bcfcdae, committed 2019-07-20
- Comitter:
- airaen0129
- Date:
- Sat Jul 20 02:11:20 2019 +0000
- Parent:
- 0:5f93dfb618bf
- Commit message:
- ledPWM + bt + flexSensor
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Jul 19 05:41:58 2019 +0000
+++ b/main.cpp Sat Jul 20 02:11:20 2019 +0000
@@ -6,13 +6,29 @@
#include "mbed.h"
#include "Map.hpp"
+Serial pc(USBTX, USBRX);
+Serial bt(PA_9, PA_10);
+PwmOut ledPWM(PA_1);
AnalogIn flexSensor(PA_7);
-Map map(0.9, 0.99999999, 0, 10000);
+Map map(0.8, 1.0, 0, 4);
+
int main() {
- while (true) {
- float analogValue = flexSensor;
+ int analogValueLevel;
+
+ pc.baud(115200);
+ bt.baud(115200);
+ ledPWM.period(0.01f);
+ ledPWM = 0.0f;
+
+ pc.printf("Hello World! HC-06 bluetooth example...\n\r");
+
+ while (true) {
+ analogValueLevel = (int)map.Calculate(flexSensor);
- wait(0.5);
- printf("%d\n", (int)map.Calculate(analogValue));
+ bt.printf("%d\n", analogValueLevel);
+
+ ledPWM = 0.25f * analogValueLevel;
+
+ wait(0.5f);
}
}