int motor1Pin1 = 27;
int motor1Pin2 = 26;
int enable1Pin = 14;
int botaoA = 33;
int botaoH = 32;
int botaoD = 35;
const int freq = 30000;
const int pwmChannel = 0;
const int resolution = 8;
int dutyCycle = 200;
void setup() {
// sets the pins as outputs:
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(enable1Pin, OUTPUT);
pinMode(botaoA, INPUT);
pinMode(botaoH, INPUT);
pinMode(botaoD, INPUT);
// configure LED PWM functionalitites
//ledcSetup(pwmChannel, freq, resolution);
// attach the channel to the GPIO to be controlled
//ledcAttachPin(enable1Pin, pwmChannel);
Serial.begin(9600);
// testing
Serial.print("Testing DC Motor...");
}
void loop() {
ledcWrite(pwmChannel, dutyCycle);
if(digitalRead(botaoH)==1){
Serial.println("Horário");
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
delay(2000);
}
if(digitalRead(botaoD)==1){
Serial.println("Motor parado");
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
delay(1000);
}
if(digitalRead(botaoA)==1){
Serial.println("Antihorário");
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
delay(2000);
}
}