Backup Rotobel

download Backup Rotobel

of 2

Transcript of Backup Rotobel

  • 8/15/2019 Backup Rotobel

    1/2

    #define SENZOR_LINIE0 A0#define SENZOR_LINIE1 A1#define PRAG 300#define SPEED 150#define FRANA 0int MOTOR2_PIN1 = 3;int MOTOR2_PIN2 = 5;int MOTOR1_PIN1 = 6;int MOTOR1_PIN2 = 9;bool start=false;void setup() {  pinMode(MOTOR1_PIN1, OUTPUT);  pinMode(MOTOR1_PIN2, OUTPUT);  pinMode(MOTOR2_PIN1, OUTPUT);  pinMode(MOTOR2_PIN2, OUTPUT);  Serial.begin(9600); }

    void loop() {

      int sensorRightValue = analogRead(SENZOR_LINIE0);  int sensorLeftValue = analogRead(SENZOR_LINIE1);  Serial.print(" SENZOR 1: ");

      Serial.print(sensorRightValue);  Serial.print(" SENZOR 2: ");  Serial.println(sensorLeftValue);  Serial.println(start);  delay(1);

      if (sensorRightValue >= 700 && sensorLeftValue >= 700)  // if(start==false) {go(SPEED,SPEED); delay(500);start=true; }  //else

    go(0,0);  if (sensorLeftValue

  • 8/15/2019 Backup Rotobel

    2/2

      analogWrite(MOTOR1_PIN2, 0);  }  else {  analogWrite(MOTOR1_PIN1, 0);  analogWrite(MOTOR1_PIN2, -speedLeft);  }

      if (speedRight > 0) {  analogWrite(MOTOR2_PIN1, speedRight);  analogWrite(MOTOR2_PIN2, 0);  } else {  analogWrite(MOTOR2_PIN1, 0);  analogWrite(MOTOR2_PIN2, -speedRight);  }}