RKI aangepast 10:02
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of Project_script_union by
main.cpp
- Committer:
- MarijkeZondag
- Date:
- 2018-10-15
- Revision:
- 7:f32005d13749
- Parent:
- 6:f4bbb73f3989
- Child:
- 8:895d941a5910
File content as of revision 7:f32005d13749:
#include "mbed.h" #include "MODSERIAL.h" DigitalOut directionpin1(D4); PwmOut pwmpin1(D5); AnalogIn potmetervalue1(A1); DigitalIn button2(D9); //klopt dit? DigitalIn encoderA(D9); DigitalIn encoderB(D8); DigitalOut directionpin2(D7); PwmOut pwmpin2(D6); AnalogIn potmetervalue2(A2); DigitalIn button1(D10); //klopt dit? MODSERIAL pc(USBTX, USBRX); int main() { pc.baud(115200); pc.printf("hello\n\r"); pwmpin1.period_us(60); //60 microseconds PWM period, 16.7 kHz while (true) { float u1 = potmetervalue1; float u2 = potmetervalue2; float m1 = ((u1*2.0f)-1.0f); float m2 = ((u2*2.0f)-1.0f); int Ea = encoderA; int Eb = encoderB; int static Eas = 0; int static Ebs = 0; pwmpin1 = fabs(m1*0.6f)+0.4f; //pwm duty cycle can only be positive, floating, 0.4f is "inefficiënt", dit tellen we erbij op, en keer 0.6 om te corrigeren voor de helling. directionpin1.write(m1>0); //Indien waar, motor draait rechtsom. Indien niet waar, motor draait linksom. wait(0.01f); //zodat de code niet oneindig doorgaat. pwmpin2 = fabs(m2*0.6f)+0.4f; directionpin2.write(m2>0); if(A==1 && A>B) { } }