Cornfield Cruisers / Mbed 2 deprecated TurnPotMotorPWM

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
pridgejg
Date:
Wed Sep 11 20:04:16 2019 +0000
Commit message:
Code for Turnpot w/ motor ;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 11 20:04:16 2019 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+#include <iostream>
+#include <math.h>
+
+//Serial bt(PTE0,PTE1);//  Bluetooth
+PwmOut duty(PTA5);// pwm output
+AnalogIn pot(PTB0); // potentiometer to adjust motor speed
+DigitalOut myled(LED1);
+
+int main() {
+    duty.period(0.00005);
+ //   bt.baud(115200);// setting the baud rate
+ //   bt.printf("We runnin' boys \n\r");
+
+    while(true) {
+      int loopCounter = 1;
+     while(loopCounter<20000){ 
+     
+        float potPercent = pot.read(); // takes value from potentiometer
+        duty.write(potPercent);
+       
+   loopCounter++;
+       } 
+    cout << "\r\n TurnPot IN:"  << (pot) << endl; 
+    cout << "\r\n PWM OUT:"  << (duty) << endl; 
+    }   
+     
+} 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 11 20:04:16 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file