Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //g++ -o servo servo.cc -lwiringPi -lpthread
- #include <iostream>
- #include <wiringPi.h>
- #include <softPwm.h>
- using namespace std;
- #define BARRIERE0 26//pwm0 BCM12 PIN 32
- #define BARRIERE1 23//pwm1 BCM13 PIN 33
- #define INIT_VALUE 4//Valeur initial servo moteur
- #define RANGE 200//Valeur final servo moteur
- int main (){
- int degrees0(4);
- int degrees1(4);
- if (wiringPiSetup()==-1 ) {cout <<"Erreur !"<<endl;return 1;}
- softPwmCreate(BARRIERE0,INIT_VALUE,RANGE);
- delay(10);
- softPwmCreate(BARRIERE1,INIT_VALUE,RANGE);
- delay(10);
- //Control Barriere 3 - 13
- while (TRUE){
- cin>>degrees0;
- if (degrees0>RANGE/10){degrees0=3;}
- softPwmWrite(BARRIERE0,degrees0);
- cin>>degrees1;
- if (degrees1>RANGE/10){degrees1=3;}
- softPwmWrite(BARRIERE1,degrees1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement