Samenwerking Groep 12
Dependencies: Encoder MODSERIAL HIDScope mbed
Foo
Diff: main.cpp
- Revision:
- 12:af428d56b4eb
- Parent:
- 10:e923f51f18c4
- Child:
- 13:a0113cf2fc5f
--- a/main.cpp Mon Sep 21 13:18:29 2015 +0000 +++ b/main.cpp Mon Sep 21 13:59:59 2015 +0000 @@ -16,7 +16,7 @@ motor2.setPosition(0); while(true) { if (button.read() < 0.5) { //if button pressed - motor2direction = 1; + motor2direction = 0; motor2speed = 0.5f; pc.printf("positie = %d \r\n", motor2.getPosition()); } else { // If button is not pressed @@ -24,29 +24,12 @@ motor2speed = 0; pc.printf("positie = %d \r\n", motor2.getPosition()); } - - while (motor2.getPosition() > 4200) { + + while ((motor2.getPosition()>4200) || (motor2.getPosition()<-4200)) // If value is outside -4200 and 4200 (number of counts equal to one revolution) reset to zero + { motor2.setPosition(0); - pc.printf("Call foo! The cake is a lie!! \r\n"); + pc.printf("HE \r\n LLO \r\n WO \r\n RLD \r\n !!! \r\n FOO! \r\n"); break; - } + } } -} - - -//#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()); -// } -//} + } \ No newline at end of file