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: mbed QEI HIDScope Motor biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 11:5171ac607099
- Parent:
- 10:9101c7a4f219
- Child:
- 12:597f6b8224e5
--- a/main.cpp Fri Sep 20 12:07:59 2019 +0000
+++ b/main.cpp Fri Sep 20 12:51:20 2019 +0000
@@ -2,41 +2,46 @@
#include "MODSERIAL.h";
#include "FastPWM.h" ;
#include "QEI.h" ;
+#include "Motor.h" ;
Serial pc(USBTX,USBRX);
-InterruptIn button1(PTC2);
-InterruptIn button2(PTC3);
-InterruptIn button3(PTA4);
-InterruptIn button4(PTC6);
-
AnalogIn pot(PTB2);
+InterruptIn button(PTB3);
FastPWM motor(D5);
FastPWM led(PTA1);
-//DigitalOut richting(D4);
-
-//int direction = 0;
-//void flip() {
-// direction = !direction;
-//}
-
-//DigitalOut richting(D4);
int pulses = 131;
QEI wheel (D13,D12,NC,pulses);
+int pin;
+
+void flip()
+{
+ pin=!pin;
+}
+
+
int main()
{
- printf("Controll with dial\n");
- while(true)
- {
- wait(0.1);
- printf("motor speeed is (%f)\n\r",pot.read());
- wait(0.1);
+ printf("Control with dial\n");
+ button.rise(&flip);
+ while(true)
+ {
+ if (pin == 1)
+ {
led.write(pot);
motor.write(pot);
- wait(0.1);
+ printf("motor speeed is (%f)\n\r",pot.read());
printf("pulse number is (%i)\n\r",wheel.getPulses());
- }
+ }
+ else
+ {
+ led.write(pot);
+ motor.write(-pot);
+ printf("motor speeed is (%f)\n\r",pot.read());
+ printf("pulse number is (%i)\n\r",wheel.getPulses());
+ }
+ }
}
\ No newline at end of file