Biorobotics / Mbed 2 deprecated Hidscope_encoder

Dependencies:   HIDScope mbed

Committer:
yohoo15
Date:
Wed Sep 23 09:20:39 2015 +0000
Revision:
0:27d918875644
Encoder with motor control

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yohoo15 0:27d918875644 1 #include "mbed.h"
yohoo15 0:27d918875644 2 #include "HIDScope.h"
yohoo15 0:27d918875644 3
yohoo15 0:27d918875644 4
yohoo15 0:27d918875644 5 // Define pin for motor control
yohoo15 0:27d918875644 6 DigitalOut dirPin(D4);
yohoo15 0:27d918875644 7 DigitalOut PWM(D5);
yohoo15 0:27d918875644 8
yohoo15 0:27d918875644 9 // Define the HIDScope and Ticker object
yohoo15 0:27d918875644 10 HIDScope scope(1); //
yohoo15 0:27d918875644 11 Ticker scopeTimer;
yohoo15 0:27d918875644 12
yohoo15 0:27d918875644 13 // Read the analog input
yohoo15 0:27d918875644 14 AnalogIn a0(PTC10);
yohoo15 0:27d918875644 15
yohoo15 0:27d918875644 16
yohoo15 0:27d918875644 17
yohoo15 0:27d918875644 18
yohoo15 0:27d918875644 19 // The data read and send function
yohoo15 0:27d918875644 20 void scopeSend()
yohoo15 0:27d918875644 21 {
yohoo15 0:27d918875644 22 scope.set(0,a0.read());
yohoo15 0:27d918875644 23 scope.send();
yohoo15 0:27d918875644 24 }
yohoo15 0:27d918875644 25
yohoo15 0:27d918875644 26
yohoo15 0:27d918875644 27 int main()
yohoo15 0:27d918875644 28 {
yohoo15 0:27d918875644 29 // Attach the data read and send function at 100 Hz
yohoo15 0:27d918875644 30 scopeTimer.attach_us(&scopeSend, 1e4);
yohoo15 0:27d918875644 31
yohoo15 0:27d918875644 32 while(1) { // let the motor run
yohoo15 0:27d918875644 33 dirPin.write(0);
yohoo15 0:27d918875644 34 PWM.write(1);
yohoo15 0:27d918875644 35
yohoo15 0:27d918875644 36 }
yohoo15 0:27d918875644 37
yohoo15 0:27d918875644 38
yohoo15 0:27d918875644 39
yohoo15 0:27d918875644 40
yohoo15 0:27d918875644 41
yohoo15 0:27d918875644 42 }
yohoo15 0:27d918875644 43
yohoo15 0:27d918875644 44
yohoo15 0:27d918875644 45
yohoo15 0:27d918875644 46
yohoo15 0:27d918875644 47
yohoo15 0:27d918875644 48
yohoo15 0:27d918875644 49
yohoo15 0:27d918875644 50