Hi, I have this simple code here which outputs power from port 13 if HIGH power is in 7. However, I found that it takes 8 seconds (yes, 8!) to run the loop function and realize that a condition has changed. Is there some way to speed this up? I know I can use traditional C statements for digitalWrite (such as PORTB |= _BV(PB5); ) but I am not sure if there is anything else I'm doing wrong. Otherwise, the code works fine, it just takes way too damn long to run loop().
int motorPin = 13;
int buttonPin = 7;
int val = 0;
void setup() {
pinMode(motorPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
val = digitalRead(buttonPin);
if (val == HIGH) {
digitalWrite(motorPin, HIGH);
} else {
digitalWrite(motorPin, LOW);
}
}