승규 김
/
flexSensor_PWM_bt
flexSensor + ledPWM + bluetooth
Diff: main.cpp
- Revision:
- 1:0e180bcfcdae
- Parent:
- 0:5f93dfb618bf
diff -r 5f93dfb618bf -r 0e180bcfcdae main.cpp --- 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); } }