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: Encoder HIDScope MODSERIAL mbed QEI biquadFilter
Revision 4:96e47998d495, committed 2015-09-30
- Comitter:
- bscheltinga
- Date:
- Wed Sep 30 15:19:10 2015 +0000
- Parent:
- 3:2785a945b654
- Child:
- 5:d60a42727a3e
- Commit message:
- control motorspeed with 4 buttons
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Sep 23 09:10:59 2015 +0000
+++ b/main.cpp Wed Sep 30 15:19:10 2015 +0000
@@ -1,18 +1,37 @@
#include "mbed.h"
-#include "HIDScope.h"
#include "encoder.h"
#include "MODSERIAL.h"
//Motor 2
DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield)
PwmOut motor2speed(D5);
-DigitalIn button(PTA4);
+DigitalIn buttonL1(PTC6);
+DigitalIn buttonL2(PTA4);
+DigitalIn buttonH1(D2);
+DigitalIn buttonH2(D6);
+
+//dit kan worden gebruikt om de verschillende slagnelheden toe te passen door de buttons te veranderen in thresholds
int main()
{
- for (int n = 0; n < 10; n++) {
- motor2direction = 1;
- motor2speed = 0.1f*n;
- wait (2);
+ while(true) {
+ if (buttonL1.read() <0.5) {
+ motor2speed = 0.1;
+ motor2direction = 0;
+ }
+ if (buttonL2.read() <0.5) {
+ motor2speed = 0.4;
+ motor2direction = 0;
+ }
+ if (buttonH1.read() <0.5) {
+ motor2speed = 0.7;
+ motor2direction = 0;
+ }
+ if (buttonH2.read() <0.5) {
+ motor2speed = 0.99999;
+ motor2direction = 0;
+ } else {
+ motor2speed =0;
+ }
}
-}
\ No newline at end of file
+}
