Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. const int pwm = 3 ;
  2. const int in_1 = 18 ;
  3. const int in_2 = 19 ;
  4.  
  5. //For providing logic to L298 IC to choose the direction of the DC motor
  6.  
  7. void setup()
  8. {
  9. Serial.begin(9600);
  10. pinMode(pwm,OUTPUT) ; //we have to set PWM pin as output
  11. pinMode(in_1,OUTPUT) ; //Logic pins are also set as output
  12. pinMode(in_2,OUTPUT) ;
  13. }
  14.  
  15. void loop()
  16. {
  17. //For Clock wise motion , .in_1 = High , in_2 = Low
  18. analogWrite(pwm,150) ;
  19. digitalWrite(in_1,HIGH) ;
  20. digitalWrite(in_2,LOW) ;
  21. delay(1000);
  22.  
  23.  
  24. digitalWrite(in_1,LOW) ;
  25. digitalWrite(in_2,HIGH) ;
  26. delay(1000) ;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement