Samenwerking Groep 12
Dependencies: Encoder MODSERIAL HIDScope mbed
Foo
main.cpp
- Committer:
- ThomasBNL
- Date:
- 2015-09-21
- Revision:
- 12:af428d56b4eb
- Parent:
- 10:e923f51f18c4
- Child:
- 13:a0113cf2fc5f
File content as of revision 12:af428d56b4eb:
#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 = 0; 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.getPosition()<-4200)) // If value is outside -4200 and 4200 (number of counts equal to one revolution) reset to zero { motor2.setPosition(0); pc.printf("HE \r\n LLO \r\n WO \r\n RLD \r\n !!! \r\n FOO! \r\n"); break; } } }