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: Motor mbed millis PID
Diff: main.cpp
- Revision:
- 1:8d4fab4e069c
- Parent:
- 0:24cb158c4064
- Child:
- 2:7565fb31357d
diff -r 24cb158c4064 -r 8d4fab4e069c main.cpp
--- a/main.cpp Thu Sep 22 15:14:41 2016 +0000
+++ b/main.cpp Fri Sep 23 12:29:17 2016 +0000
@@ -1,5 +1,6 @@
#include "mbed.h"
#include "millis.h"
+#include "Motor.h"
int val;
@@ -9,24 +10,29 @@
float rpm;
int start = 1;
unsigned long int previousMillis = 0;
-
+ float pwmRead=0.00;
+
+ Motor motor1(D11,D13,D12);
+ AnalogIn pwmIn(A0);
+
int main(void) {
-
+
DigitalIn encoder0PinA(D3);
DigitalIn encoder0PinB(D4);
Serial pc(USBTX,USBRX);
- pc.baud(9600);
+
startMillis();
+
while(1){
- // AnalogIn(A0);
-
+ pwmRead = pwmIn.read();
+ motor1.speed(pwmRead/255);
unsigned long int currentMillis = millis();
// int counter;
// counter=currentMillis/100;
- if (currentMillis-previousMillis==500)
+ if (currentMillis-previousMillis>=500)
{
previousMillis = currentMillis;
rpm = 120.0/7.0*encoder0Pos;