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 biquadFilter MODSERIAL FastPWM
Revision 14:20f11bb58244, committed 2019-09-23
- Comitter:
- Hendrikvg
- Date:
- Mon Sep 23 08:17:52 2019 +0000
- Parent:
- 9:12b9865e7373
- Child:
- 15:80b3ac2b8448
- Commit message:
- Motor 1 aan en uit zetten werkt, snelheid en richting aansturen nog niet.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Sep 19 14:41:31 2019 +0000
+++ b/main.cpp Mon Sep 23 08:17:52 2019 +0000
@@ -1,10 +1,16 @@
#include "mbed.h"
+#include "FastPWM.h"
+
+// Motor 1 aan zetten en uit zetten dmv button 1 en 2 werkt.
+// Snelheid aansturen nog niet.
Serial pc(USBTX,USBRX);
InterruptIn BUT1(D1);
InterruptIn BUT2(D0);
-PwmOut lichtje(D3);
+FastPWM lichtje(D3);
AnalogIn ain(A0);
+DigitalOut direction(D6);
+DigitalOut speed(D7);
float getal;
int n=5;
@@ -12,6 +18,7 @@
void plus()
{
n++; // n=n+1
+ direction = 1;
if (n>10){
n=10;
}
@@ -20,6 +27,7 @@
void min()
{
n--;
+ direction = 0;
if (n<0){
n=0;
}
@@ -32,10 +40,12 @@
BUT2.fall(min);
while(true)
{
- getal = 0.01*n*ain.read();
- lichtje.period(4.0f); // 4 second period
+ getal = 0.1*n*ain.read();
+ speed = 0.1*n*ain.read();
+ lichtje.period_ms(20); // 4 second period
lichtje.write(getal); // duty cycle
- pc.printf("%3.3f%\n\r", ain.read());
+ speed.write(getal);
+ pc.printf("%3.3f%\n\r", getal);
}
}
\ No newline at end of file