i need a help i cant create single inverse signal by millis. my code cyclical delay but i need single by millis
please who can help to show me example
i need a help i cant create single inverse signal by millis. my code cyclical delay but i need single by millis
please who can help to show me example
i need a two single also needs a shift for the second signal
thank you my code))
I wanted a signal to be executed on a single press. but if pressing the button falls into the timing, then the signal is triggered accordingly if you wait a long time and press the button nothing happens))) how can I fix unsigned long previousMillis = 0;
thanks a lot for the code
#define load_button 9
const int ledPin = 11;
const int ledPin2 = 12;
// Variables will change:
int ledState = LOW; // ledState used to set the LED
int ledState2 = LOW;
// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
// will store last time LED was updated
unsigned long previousMillis = 0;
void setup() {
// set the digital pin as output:
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(load_button, INPUT_PULLUP);
}
void signal(){
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 0 && currentMillis - previousMillis <= 1000) {
digitalWrite(ledPin,HIGH);
}
else{
digitalWrite(ledPin,LOW);
}
if (currentMillis - previousMillis >= 400 && currentMillis - previousMillis <= 5000) {
digitalWrite(ledPin2,HIGH);
}
else{
digitalWrite(ledPin2,LOW);
}
}
void loop() {
if (digitalRead(load_button) == LOW) {
signal();
}
}