Hello,
Can someone tell me why my led's on my UNO are dim while the millis delay function is active. I am a beginner! The code works like I want it to but for some reason the led's go dim while the countdown is active. I'm supposing something in my code is incorrect. I am using pull-down resistors on my breadboard.
byte sensorOne = 2;
byte feedOne = 8;
byte augerOne = 16;
unsigned long feedEmptyMillis; // when feed level dropped below sensor
unsigned long turnOnDelay = 3000; // wait to turn on auger
unsigned long turnOffDelay = 10000; // turn off auger after this time
void setup() {
// put your setup code here, to run once:
pinMode (sensorOne, INPUT);
pinMode (feedOne, OUTPUT);
pinMode (augerOne, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
boolean prox1 = digitalRead (sensorOne);
if (prox1 == LOW)
{
digitalWrite (feedOne, LOW);
digitalWrite(augerOne, HIGH);
}
if (prox1 == HIGH)
feedEmptyMillis = currentMillis;
if (currentMillis - feedEmptyMillis <= turnOnDelay)
{
digitalWrite (augerOne, LOW);
}
if (currentMillis - feedEmptyMillis <= turnOffDelay)
{
digitalWrite (feedOne, HIGH);
}
}