daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Arduino.h>
  2. #include <Wire.h>
  3. #include <SoftwareSerial.h>
  4.  
  5. #include <MeMCore.h>
  6.  
  7. MeDCMotor motor_9(9);
  8. MeDCMotor motor_10(10);
  9. void move(int direction, int speed)
  10. {
  11.       int leftSpeed = 0;
  12.       int rightSpeed = 0;
  13.       if(direction == 1){
  14.             leftSpeed = speed;
  15.             rightSpeed = speed;
  16.       }else if(direction == 2){
  17.             leftSpeed = -speed;
  18.             rightSpeed = -speed;
  19.       }else if(direction == 3){
  20.             leftSpeed = -speed;
  21.             rightSpeed = speed;
  22.       }else if(direction == 4){
  23.             leftSpeed = speed;
  24.             rightSpeed = -speed;
  25.       }
  26.       motor_9.run((9)==M1?-(leftSpeed):(leftSpeed));
  27.       motor_10.run((10)==M1?-(rightSpeed):(rightSpeed));
  28. }
  29. double angle_rad = PI/180.0;
  30. double angle_deg = 180.0/PI;
  31. MeLineFollower linefollower_2(2);
  32.  
  33. void setup(){
  34.     move(1,0);
  35.     while(!(((linefollower_2.readSensors())==(0))))
  36.     {
  37.         _loop();
  38.         move(1,100);
  39.     }
  40.     move(1,0);
  41. }
  42.  
  43. void loop(){
  44.     if(((linefollower_2.readSensors())==(2))){
  45.         move(1,100);
  46.     }
  47.     if(((linefollower_2.readSensors())==(1))){
  48.         move(2,100);
  49.     }
  50.     if(((linefollower_2.readSensors())==(3))){
  51.         move(4,100);
  52.     }
  53.     if(((linefollower_2.readSensors())==(0))){
  54.         move(3,100);
  55.     }
  56.     _loop();
  57. }
  58.  
  59. void _delay(float seconds){
  60.     long endTime = millis() + seconds * 1000;
  61.     while(millis() < endTime)_loop();
  62. }
  63.  
  64. void _loop(){
  65. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top