Samenwerking Groep 12
Dependencies: Encoder MODSERIAL HIDScope mbed
Foo
Diff: main.cpp
- Revision:
- 7:b2b1d1c36861
- Parent:
- 6:e743bf8b9a59
- Child:
- 8:a41b2d8f6e74
--- a/main.cpp Mon Sep 21 11:31:29 2015 +0000 +++ b/main.cpp Mon Sep 21 11:37:40 2015 +0000 @@ -1,47 +1,46 @@ +#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); +Encoder motor2(D13,D12); +MODSERIAL pc(USBTX,USBRX); + + +int main() +{ + pc.baud(9600); + while(true) { + if (button.read() < 0.5) { //if button pressed + motor2direction = 1; + motor2speed = 0.5f; + pc.printf("positie = %d \r\n", motor2.getPosition()); + } else { // If button is not pressed + motor2direction = 0; + motor2speed = 0; + motor2.setPosition(0); + pc.printf("positie = %d \r\n", motor2.getPosition()); + } + } +} +// //#include "mbed.h" +//#include "MODSERIAL.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); -//Encoder motor2(D13,D12); +//Encoder encoder1(D13,D12); //MODSERIAL pc(USBTX,USBRX); // -// //int main() //{ +// encoder1.setPosition(0); // pc.baud(9600); -// while(true) { -// if (button.read() < 0.5) { //if button pressed -// motor2direction = 1; -// motor2speed = 0.5f; -// pc.printf("positie = %d \n", motor2.getPosition()); -// } else { // If button is not pressed -// motor2direction = 0; -// motor2speed = 0; -// motor2.setPosition(0); -// pc.printf("positie = %d \n", motor2.getPosition()); -// } +// while (true) { +// pc.printf("position: %d \r\n", encoder1.getPosition()); // } //} - - -#include "mbed.h" -#include "MODSERIAL.h" -#include "HIDScope.h" -#include "encoder.h" - -Encoder foo(D13,D12); -MODSERIAL pc(USBTX,USBRX); - -int main() -{ - foo.setPosition(0); - pc.baud(9600); - while (true) { - pc.printf("position: %d, speed: %.20f\r\n", encoder1.getPosition(), encoder1.getSpeed()); - } -}