I finally got this little counter to work so thank you for your help ![Smile :)]()
This is the final code that I use as main.py
I created an extra file called func.py where I put the counting that you sent to me ghp so the final main-file would look a little better and perhaps easier to read.
Thank you once again and now it's just putting it all together in a nice little box left![Smile :)]()

This is the final code that I use as main.py
Code:
from machine import I2C, Pinfrom time import sleepfrom urtc import DS1307from pico_i2c_lcd import I2cLcdfrom func import * i2c_lcd = I2C(id=1,scl=Pin(3),sda=Pin(2),freq=100000)lcd = I2cLcd(i2c_lcd, 0x27, 2, 16)i2c_rtc = I2C(0,scl = Pin(17),sda = Pin(16),freq = 400000)result = I2C.scan(i2c_rtc)rtc = DS1307(i2c_rtc)button = machine.Pin(14, machine.Pin.IN, machine.Pin.PULL_UP)button2 = machine.Pin(4, machine.Pin.IN, machine.Pin.PULL_UP)button3 = machine.Pin(5, machine.Pin.IN, machine.Pin.PULL_UP)button4 = machine.Pin(6, machine.Pin.IN, machine.Pin.PULL_UP)(year,month,date,day,hour,minute,second,p1)=rtc.datetime()string = rtc.datetime()t = (year, month, date)while True: lcd.move_to(3,0) lcd.putstr("Welcome :)") lcd.move_to(1,1) lcd.putstr("Date:") lcd.move_to(6,1) lcd.putstr(str(year) + "/" + str(month) + "/" + str(date)) if button.value() ==0: lcd.clear() lcd.move_to(2,0) lcd.putstr("Best Before:") lcd.move_to(1,1) lcd.putstr(str(get_date(t,2))) sleep(5) lcd.clear() elif button2.value()==0: lcd.clear() lcd.move_to(2,0) lcd.putstr("Best Before:") lcd.move_to(1,1) lcd.putstr(str(get_date(t,4))) sleep(5) lcd.clear() elif button3.value()==0: lcd.clear() lcd.move_to(2,0) lcd.putstr("Best Before:") lcd.move_to(1,1) lcd.putstr(str(get_date(t,5))) sleep(5) lcd.clear() elif button4.value()==0: lcd.clear() lcd.move_to(2,0) lcd.putstr("Best Before:") lcd.move_to(1,1) lcd.putstr(str(get_date(t,9))) sleep(5) lcd.clear()
Thank you once again and now it's just putting it all together in a nice little box left

Statistics: Posted by per.danielsson — Fri Nov 29, 2024 6:29 pm