Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int pwm = 3 ;
- const int in_1 = 18 ;
- const int in_2 = 19 ;
- //For providing logic to L298 IC to choose the direction of the DC motor
- void setup()
- {
- Serial.begin(9600);
- pinMode(pwm,OUTPUT) ; //we have to set PWM pin as output
- pinMode(in_1,OUTPUT) ; //Logic pins are also set as output
- pinMode(in_2,OUTPUT) ;
- }
- void loop()
- {
- //For Clock wise motion , .in_1 = High , in_2 = Low
- analogWrite(pwm,150) ;
- digitalWrite(in_1,HIGH) ;
- digitalWrite(in_2,LOW) ;
- delay(1000);
- digitalWrite(in_1,LOW) ;
- digitalWrite(in_2,HIGH) ;
- delay(1000) ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement