Pushbutton Toggled Blinking LEDs

I'm working on a project which involves a two momentary switches and two (or more) LEDs.
I'm trying to use the momentary switches as toggle switches, to make the respective LEDs blink in .5 second intervals or to turn them off.
The momentary switch toggle issue is pretty well solved, but it's a little buggy.
My main issue is with making the LEDs blink. I can turn them steady on and off just fine, but I can't make them blink.

Here are a few snippets of code:

The toggle:


if(digitalRead(rightButton) == HIGH){
// Compare value read at RTS button to previously stored value and check if RTS is off
if(rightOn == false){ // If boolean variable "rightOn" is FALSE...
blinkRightLed();
digitalWrite(leftLed, LOW); // ...Turn left LED off
}
else{
// If boolean variable "rightOn" is TRUE...
digitalWrite(rightLed, LOW); // ...Turn right LED off
}
rightOn = !rightOn; // Switch state of boolean variable "rightOn" for next loop
}


The blink:


void blinkRightLed(){
totalTime = millis();
if(totalTime - lastTime > interval){
digitalWrite(rightLed, HIGH);
}
else{
digitalWrite(rightLed, LOW);
}
lastTime = totalTime;
}


Thanks for the help!

Hi and welcome to the forum,

I guess it's hard for people to answer your question. With just 2 pieces of code it's hard to see what goes wrong. If you send the complete sketch, people can test it and it becomes much easier to analyse.

Posting code can be done by clicking the #-button in the message menu. You'll see two commands, [ code ] and [ /code ]. If you place your code between 'm, you'll get something like this after sending your message :

if(digitalRead(rightButton) == HIGH){
// Compare value read at RTS button to previously stored value and check if RTS is off
    if(rightOn == false){ // If boolean variable "rightOn" is FALSE...
      blinkRightLed();
      digitalWrite(leftLed, LOW); // ...Turn left LED off
      }
  else{
// If boolean variable "rightOn" is TRUE...
    digitalWrite(rightLed, LOW); // ...Turn right LED off
    }
    rightOn = !rightOn; // Switch state of boolean variable "rightOn" for next loop
  }