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: FastPWM HIDScope MODSERIAL mbed
Revision 5:9827fabbc692, committed 2018-11-01
- Comitter:
- Mirjam
- Date:
- Thu Nov 01 08:52:14 2018 +0000
- Parent:
- 4:c73ced5d5754
- Commit message:
- Working potmeter demo
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Sep 25 14:02:15 2018 +0000
+++ b/main.cpp Thu Nov 01 08:52:14 2018 +0000
@@ -4,17 +4,28 @@
#include "HIDScope.h"
+/*
+Hallo!
+
+Het is tijd om de demo mode met behulp van potmeters te laten draaien :)
+Zorg ervoor dat de potmeters met de draadjes aan de juiste poorten op de MBed zijn gekoppeld.
+Het zijn de twee helemaal links onderin.
+
+Veel succes ermee en wees voorzichtig!
+*/
+
AnalogIn potmeter1(PTC10);
AnalogIn potmeter2(PTC11);
MODSERIAL pc(USBTX, USBRX);
+
//D4 is a digital input for the microcontroller, so should be an digitalOut
-//from the K64F. It will tell the motor shiel to let Motor1 turn clockwise
-//of count clockwise (CW of CCW). D4 for motor 2
+//from the K64F. It will tell the motor shield to let Motor1 turn clockwise
+//or counter clockwise (CW of CCW). D7 for motor 2
DigitalOut directionM1(D4);
DigitalOut directionM2(D7);
//D5 is a PWM input for the motor controller and determines the PWM signal
-//that the motor controller gives to Motor 1. Higher PWM, higer average voltage.
-// D6 for motor 2
+//that the motor controller gives to Motor 1. Higher PWM, higher average voltage.
+//D6 for motor 2
FastPWM motor1_pwm(D5);
FastPWM motor2_pwm(D6);
@@ -42,8 +53,8 @@
potwaarde1 = potmeter1.read(); // Lees de potwaardes uit. Tussen 0 en 1
potwaarde2 = potmeter2.read();
- U1 = potwaarde1*2 -1; // Scale van -1 tot 1 ipv. 0 tot 1
- U2 = potwaarde2*2 -1;
+ U1 = potwaarde1 -0.5; // Scale van -0.5 tot 0.5 ipv. 0 tot 1
+ U2 = potwaarde2 -0.5;
// Gebruik de absolute waarde van de scaled U waardes als input voor de motor.
// Negatieve waardes kunnen niet naar de motor gestuurd worden.
@@ -55,5 +66,4 @@
wait(0.002f);
}
-
}
\ No newline at end of file