Advertisement
Guest User

tommotor

a guest
May 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int motorPin1  = 9;  // Pin 14 of L293
  2. const int motorPin2  = 10;  // Pin 10 of L293
  3. const int isenabled = XX;
  4. const int ismanual = XX;
  5. const int isautomatic = XX;
  6. const int btn_up = XX;
  7. const int btn_down = XX;
  8. //Motor B
  9. //const int motorPin3  = 6; // Pin  7 of L293
  10. //const int motorPin4  = 5;  // Pin  2 of L293
  11.  
  12. #define distance 7000
  13.  
  14. void setup() {
  15.   // put your setup code here, to run once:
  16.   pinMode(motorPin1, OUTPUT);
  17.     pinMode(motorPin2, OUTPUT);
  18.  
  19.     pinMode(isenabled,INPUT);
  20.     pinMode(isautomatic,INPUT);
  21.     pinMode(ismanual,INPUT);
  22.     pinMode(btn_dow1n,INPUT);
  23.     pinMode(btn_up,INPUT);
  24. }
  25.  
  26. void loop() {
  27.   if(isenabled == HIGH){
  28.     if(ismanual == HIGH){
  29.        while(ismanual == HIGH){
  30.         if(btn_up == HIGH){
  31.         while(btn_up == HIGH){
  32.              analogWrite(motorPin1,200);//end utga ni ymar neg too bn.
  33.              analogWrite(motorPin2,0);
  34.         }
  35.         }
  36.         if(btn_down == HIGH){
  37.         while(btn_down == HIGH){
  38.              analogWrite(motorPin1,200);
  39.              analogWrite(motorPin2,10);//end utga ni ymar neg too bn.
  40.         }
  41.         }
  42.        }
  43.     }
  44.     else if(isautomatic == HIGH){
  45.     if (lightvalue > 750)
  46.     {
  47.     analogWrite(motorPin1,distance);
  48.     analogWrite(motorPin2,0);
  49.     }
  50.     else if(lightvalue < 350)
  51.     {  
  52.     analogWrite(motorPin1,0);
  53.     analogWrite(motorPin2,distance);
  54.     }
  55.   }
  56.   else{
  57.     delay(1000);
  58.   }
  59.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement