Samenwerking Groep 12
Dependencies: Encoder MODSERIAL HIDScope mbed
Foo
Diff: main.cpp
- Revision:
- 10:e923f51f18c4
- Parent:
- 9:0a7981d2da8a
- Child:
- 12:af428d56b4eb
- Child:
- 14:7603d7f1dbe9
--- a/main.cpp Mon Sep 21 12:46:22 2015 +0000 +++ b/main.cpp Mon Sep 21 13:18:29 2015 +0000 @@ -1,46 +1,52 @@ +#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); +//AnalogIn potmeter2(A0); /NIEUW +int main() +{ + pc.baud(9600); + motor2.setPosition(0); + 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; + pc.printf("positie = %d \r\n", motor2.getPosition()); + } + + while (motor2.getPosition() > 4200) { + motor2.setPosition(0); + pc.printf("Call foo! The cake is a lie!! \r\n"); + break; + } + } +} + + //#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); -//MODSERIAL pc(USBTX,USBRX); -//AnalogIn potmeter2(A0); /NIEUW +//MODSERIAL pc(USBTX,USBRX); +//AnalogIn potmeter2(A0); +//double Convert_pot_to_speed=0.000001; // //int main() //{ // pc.baud(9600); -// motor2.setPosition(0); -// 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; -// pc.printf("positie = %d \r\n", motor2.getPosition()); -// } +// while (true) { +// pc.printf("position: %d \r\n", potmeter2.read()); // } //} -// -#include "mbed.h" -#include "MODSERIAL.h" -#include "HIDScope.h" -#include "encoder.h" - -MODSERIAL pc(USBTX,USBRX); -AnalogIn potmeter2(A0); -double Convert_pot_to_speed=0.000001; - -int main() -{ - pc.baud(9600); - while (true) { - pc.printf("position: %d \r\n", potmeter2.read()); - } -}