Help with modifying lipopi.py to include LED output

I’m trying to add a low battery LED indicator to the python code created in the lipopi page here.

I do not know how to code but can sometimes gets by doing simple things like this.  Using this page that I found about setting up a blinking LED I’m trying to modify the original file to include an LED blink output when the low battery indicator turns on.  

What I’ve done:

Added this line to add an event ‘low_battery_ledblink’ in the event that the ‘low_battery_pin’ is triggered

GPIO.add_event_detect(lipopi['low_battery_pin'], GPIO.FALLING, callback=lipopi_low_battery_ledblink, bouncetime=300)

Added this to define the ‘low_battery_ledblink’ function. (this I’m not sure that I’ve done correctly - do I need the GPIO.cleanup? will this code work for flashing an LED?)

def lipopi_low_battery_ledblink(channel):
    global lipopi

    GPIO.output(low_bat_led_pin, GPIO.HIGH) # led on
    time.sleep(.5)
    GPIO.output(low_bat_led_pin, GPIO.LOW) # led off
    time.sleep(.5)

Added this variable to define the LED pin:

lipopi['low_bat_led_pin'] = 17

Any help with ensuring this will work would be awesome, thanks!

Hi sublime8365,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our Community organized so users can more easily find information.

As you’ll notice, your Topic is now in the Project Development Help and Advice board.

Let me know if you have any other questions or if I can help with anything else.

Cheers!

Jacqui