Circuit Python LCD - adalessio84/circuitPython GitHub Wiki

LCD Screen and button

Objective

In this assignment we learn how to use buttons to count up and even down and then display it on the LCD like we did when we where learning how to use the Aurdino. The big Diffrence I have fond between the two

Pictures

Problems

In this assignment I had 2 problems, getting the LCD screen to print what I wanted, to get the button to count up without using a time.sleep constantly. This assignment was one of the more difficult ones because I had to make a code that didn’t use time.sleep as much, which, trust me, was very hard because up until now, time.sleep was the only delay type of tool I used (besides delay on Arduino). Getting what I wanted on the actual LCD screen was super hard for me. I didn't get it working until the very, infact I used the serial monitor to do all the numeric stuff involved.

What I Learned!

This assignment taught me how to use the LCD to count up and how to wire a button to it to do so. I also taught me to design a code that counted upon click instead of on delay which was helpful and interesting

Code

import math
import board
from lcd.lcd import LCD
from lcd.i2c_pcf8574_interface import I2CPCF8574Interface
from digitalio import DigitalInOut, Direction, Pull
from lcd.lcd import CursorMode
button = DigitalInOut(board.D8)

button.direction = Direction.INPUT
button.pull = Pull.UP
lcd = LCD(I2CPCF8574Interface(0x27), num_rows=4, num_cols=20)

lcd.set_cursor_pos(1, 4)
lcd.print("Here I am")
#while True:
#    lcd.print("Hello")
#    if not button.value:
#    lcd.print("Hello")
#    else:
#        print("no")
#    time.sleep(0.1)