Answer the question
In order to leave comments, you need to log in
Why does the button conflict with the motor on the Arduino?
Here is my sketch:
int analogPin = A0;
int val = 0;
#include "GyverMotor.h"
GMotor motor(DRIVER3WIRE, 7, 8, 9, HIGH);
unsigned long time_work;
int tester;
void setup() {
Serial.begin(9600);
motor.setLevel(HIGH);
//motor.setSmoothSpeed(40);
// ключ на старт!
motor.setMode(FORWARD);
//motor.setMinDuty(50);
}
void loop() {
val = analogRead(analogPin);
//Serial.println(val);
if (val < 700) {tester = 1;} // кнопка включена
if (val >= 700) {tester = 3;} // кнопка выключена
if (tester == 1 && millis() - time_work > 5000) {
time_work = millis();
tester = 0;
Serial.println("step1");
motor.smoothTick(255);
}
if (tester == 0 && millis() - time_work > 5000) {
time_work = millis();
tester = 1;
Serial.println("step2");
motor.smoothTick(0);
}
}
Answer the question
In order to leave comments, you need to log in
And what kind of perversion do you have with connecting a button?
In principle, it is possible (but not necessary) to connect 4-5 buttons to the analog input. For one button, this is idiotic.
Look at the value of val in the plotter, I think it will be interesting
in the sketch you have if (tester == 1 and if (tester == 0 about tester == 3 your sketch knows nothing
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question