I need to properly iterate an LCD number board in time with my program. I am using the millis(); command to iterate a counter, but at the same time the LCD board needs a 10ms HIGH pulse on its pin and then have the pin go LOW. I dont start having too much issue until I start also blinking an led from high to low. Having both run at the same time makes the LCD not receive a proper signal and it loses an accurate count. Is this perhaps a power issue? My thought is that perhaps when the arduino (I am using a mega 2560 btw) writes to the led pin and the LCD pin at the same time the voltage on the LCD is not high enough to give it a readable signal. I suppose what i need to know is if there is a programming issue before i go perusing a hardware issue.
Here is the code in question
void loop()
buttonState = digitalRead(buttonPin);// this will be replaced with a spray start indicator...
if (buttonState == HIGH)
{
unsigned long thumpCTimer = millis();
cleanFlag = true;
if (thumpCTimer - thumpPTimer > thumpInterval) //if another thump has been detected...
{
thumpPTimer = thumpCTimer;// reset interval timer so another thump can be detected
thumpCCounter++;// a resetable value
thumpCData++;// the daily thumps tally (may set overflow value to 999)
if (thumpCCounter - thumpPCounter == 1)
{
thumpPCounter = thumpCCounter;
Serial.print("Thump ");
Serial.println(thumpCCounter);
//ledPlus();
PORTA |= _BV(PA4);//led to HIGH
delay(15);
}
PORTA &= ~_BV(PA4);//led to LOW
}
}
else if (cleanFlag == true){
cleanUp();
}
// Lights Control
//--------------------------
if (thumpCCounter == 1)
{
PORTH &= ~_BV(PH6);//ledR to LOW
PORTH |= _BV(PH5);//ledY to HIGH
}
if (thumpCCounter == 6)
{
PORTH &= ~_BV(PH5);//ledY to LOW
PORTH |= _BV(PH4);//ledG to HIGH
}
if (thumpCCounter > 11)
{
unsigned long flashCTimer = millis();
if ((flashCTimer - flashPTimer) > flashInterval)
{
flashPTimer = flashCTimer;
if (ledGS == LOW){
ledGS = HIGH;
}
else{
ledGS = LOW;
}
if (ledGS == LOW)
{
PORTH &= ~_BV(PH4);//ledG to LOW
overSpray++;
}
else
{
PORTH |= _BV(PH4);//ledG to HIGH
}
}
}
}// ---------End Of Loop-----------