Samenwerking Groep 12

Dependencies:   Encoder MODSERIAL HIDScope mbed

Foo

Committer:
ThomasBNL
Date:
Mon Sep 21 11:14:11 2015 +0000
Revision:
4:a92d354265b2
Parent:
3:61c024f896ad
Child:
5:14f6189d86a2
print position toegevoegd motor werkt niet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThomasBNL 0:86df750eeab8 1 #include "mbed.h"
ThomasBNL 0:86df750eeab8 2 #include "HIDScope.h"
ThomasBNL 0:86df750eeab8 3 #include "encoder.h"
ThomasBNL 0:86df750eeab8 4 #include "MODSERIAL.h"
ThomasBNL 0:86df750eeab8 5
ThomasBNL 0:86df750eeab8 6 //Motor 2
ThomasBNL 0:86df750eeab8 7 DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield)
ThomasBNL 0:86df750eeab8 8 PwmOut motor2speed(D5);
ThomasBNL 0:86df750eeab8 9 DigitalIn button(PTA4);
ThomasBNL 4:a92d354265b2 10 Encoder motor2(D13,D12,true);
ThomasBNL 4:a92d354265b2 11 MODSERIAL pc(USBTX,USBRX);
ThomasBNL 4:a92d354265b2 12
ThomasBNL 0:86df750eeab8 13
ThomasBNL 0:86df750eeab8 14 int main()
ThomasBNL 0:86df750eeab8 15 {
ThomasBNL 4:a92d354265b2 16 pc.baud(9600);
ThomasBNL 0:86df750eeab8 17 while(true) {
ThomasBNL 4:a92d354265b2 18 if (button.read() < 0.5) { //if button pressed
ThomasBNL 0:86df750eeab8 19 motor2direction = 1;
bscheltinga 2:3de3c5eb400f 20 motor2speed = 0.3f;
ThomasBNL 4:a92d354265b2 21 //pc.printf("positie = %d \n", motor2.getPosition());
bscheltinga 3:61c024f896ad 22 } else { // If button is not pressed
ThomasBNL 0:86df750eeab8 23 motor2direction = 0;
ThomasBNL 4:a92d354265b2 24 motor2speed = 0;
ThomasBNL 4:a92d354265b2 25 //pc.printf("positie = %d \n", motor2.getPosition());
ThomasBNL 0:86df750eeab8 26 }
ThomasBNL 4:a92d354265b2 27 //pc.printf("positie = %d \n", motor2.getPosition());
ThomasBNL 0:86df750eeab8 28 }
ThomasBNL 0:86df750eeab8 29 }