Hello!
I am new to the Arduino use and programming.
There is a project which is controlled by a button and a potentiometer with a servo motor. The degree of servo am sending to the serial port, but only when I press the button. The problem is that the degree of servo command displays continuously without pressing the button.
#include <Servo.h>
Servo szervo1;
int pottu = 0;
int ert;
int fok;
const int gombTu = 1;
int gombAllas = 0;
void setup()
{
Serial.begin(9600);
szervo1.attach(9);
pinMode(gombTu, INPUT);
}
void loop() {
gombAllas = digitalRead(gombTu);
if (gombAllas == HIGH) {
Serial.print("Szervo1: ");
Serial.print(fok);
Serial.println(" fok");
delay (90);
}
ert = analogRead(pottu);
ert = map(ert, 0, 1023, 0, 179);
szervo1.write(ert);
fok = szervo1.read();
delay(15);
}
Regards, Bálint!