![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
vor bas
main.cpp
- Committer:
- wiesdat
- Date:
- 2014-10-31
- Revision:
- 1:d157905a98d1
- Parent:
- 0:b48b8c18b1bd
- Child:
- 2:2b64e8a0a075
File content as of revision 1:d157905a98d1:
#include "mbed.h" #include "mbed.h" #include "encoder.h" #define K_P (0.1) #define K_I (0.1) #define K_D (0.0005 /TSAMP) #define TSAMP 0.001 #define I_LIMIT 1. #include <iostream> Encoder encoderA(PTD5,PTA13); PwmOut pwm(PTC8); DigitalOut dir(PTC9); int32_t enc = 0,enca2 =0,enca1=0, encp=0, counts =0; float speed = 0.1, out =0; int pos =0,zero =0, fout; float v=0; float out_i = 0; int y; void batposition(int y) { switch(y) { case 1: cout<<"links"<<endl; dir.write(1); pwm.write(0.4); wait(0.03); pwm.write(0); break; case 2: cout<<"rechts"<<endl; dir.write(0); pwm.write(0.4); wait(0.03); pwm.write(0); break; } } int main() { while(1) { cout<<"typ 1 voor links, 2 voor rechts: "<<endl; cin>>y; batposition(y); } }