I wroted a code, whitch turns on leds by the date and color from the txt file. If the date is correct leds turns on, but when correct time passes leds wont turn off, they still glowing until next date. So, why leds won't turn off, where is the problem? Please help, I have tried almost everything.
import sys
import time
import datetime
import RPi.GPIO as GPIO
import SDL_DS1307
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
LED_R = 17
LED_G = 27
LED_B = 22
GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
filename = time.strftime("%Y-%m-%d%H:%M:%SRTCTest") + ".txt"
starttime = datetime.datetime.utcnow()
ds1307 = SDL_DS1307.SDL_DS1307(1, 0x68)
ds1307.write_now()
while True:
currenttime = datetime.datetime.utcnow()
deltatime = currenttime - starttime
data=time.strftime("%Y"+"%m"+"%d"+"%H"+"%M")
with open('data.txt') as f:
for line in f:
parts=line.split()
if parts[0]<=(data)<=parts[1]:
if parts[2]=='raudona':
GPIO.putput(LED_R, False)
GPIO.putput(LED_G, True)
GPIO.putput(LED_B, True)
elif parts[2]=='zalia':
GPIO.putput(LED_R, True)
GPIO.putput(LED_G, False)
GPIO.putput(LED_B, True)
elif parts[2]=='melyna':
GPIO.putput(LED_R, True)
GPIO.putput(LED_G, True)
GPIO.putput(LED_B, False)
elif parts[2]=='geltona':
GPIO.putput(LED_R, False)
GPIO.putput(LED_G, True)
GPIO.putput(LED_B, False)
elif parts[2]=='zydra':
GPIO.putput(LED_R, True)
GPIO.putput(LED_G, False)
GPIO.putput(LED_B, False)
elif parts[2]=='violetine':
GPIO.putput(LED_R, False)
GPIO.putput(LED_G, False)
GPIO.putput(LED_B, True)
elif parts[2]=='balta':
GPIO.putput(LED_R, False)
GPIO.putput(LED_G, False)
GPIO.putput(LED_B, False)
time.sleep(10.0)
Hey brother I believe I have found the answer to your problem. Okay here is what you will do. THIS IS A THOROUGH GUIDE ON DEBUGGING A BLINKING LED
Endeavour to go through the guide as it contains useful information on solving the issue that you are experiencing.
You see Raspberry Pi is a very interesting and unique piece of device