Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this is my example for demonstration H-bridge on n-p-n transistors (BJT - Bipolar Junction Transistors) and for PWM
- //simpleGo function is for H-bridge presentation
- //PWMmotor - simple PWM example
- //this code placed on Pastebin
- uint8_t pwm = 55;
- uint8_t step = 1;
- void setup() {
- pinMode(6, OUTPUT);
- pinMode(3, OUTPUT);
- Serial.begin(9600);
- }
- void simpleGo(){
- digitalWrite(6, 1);
- digitalWrite(3, 0);
- delay(2000);
- digitalWrite(6, 0);
- digitalWrite(3, 0);
- delay(2000);
- digitalWrite(6, 0);
- digitalWrite(3, 1);
- delay(2000);
- digitalWrite(6, 0);
- digitalWrite(3, 0);
- delay(2000);
- }
- void PWMmotor(){
- while(pwm<=254) {
- analogWrite(6, pwm);
- delay(100);
- pwm = pwm + step;
- Serial.print("INCREASE");
- Serial.println(pwm);
- }
- while(pwm>=55) {
- analogWrite(6, pwm);
- delay(100);
- pwm = pwm - step;
- Serial.print("decrease decrease decresase");
- Serial.println(pwm);
- }
- }
- void loop() {
- //simpleGo();
- //PWMmotor();
- analogWrite(6,120);
- }
Advertisement
Add Comment
Please, Sign In to add comment