# Bob Kammauff # circuitPythonLCD # https://github.com/jkammau97/CircuitPython # code from https://cvilleschools.instructure.com/courses/31071/assignments/303469 from lcd.lcd import LCD from lcd.i2c_pcf8574_interface import I2CPCF8574Interface # some LCDs are 0x3f... some are 0x27. lcd = LCD(I2CPCF8574Interface(0x3f), num_rows=2, num_cols=16) lcd.print("Hello, Engineer!")
from lcd.lcd import LCD from lcd.i2c_pcf8574_interface import I2CPCF8574Interface from lcd.lcd import CursorMode # Talk to the LCD at I2C address 0x27. # The number of rows and columns defaults to 4x20, so those # arguments could be omitted in this case. lcd = LCD(I2CPCF8574Interface(0x27), num_rows=4, num_cols=20) lcd.print("abc ") lcd.print("This is quite long and will wrap onto the next line automatically.") lcd.clear() # Start at the second line, fifth column (numbering from zero). lcd.set_cursor_pos(1, 4) lcd.print("Here I am") # Make the cursor visible as a line. lcd.set_cursor_mode(CursorMode.LINE)
from lcd.lcd import LCD from lcd.i2c_pcf8574_interface import I2CPCF8574Interface from lcd.lcd import CursorMode import time import board from digitalio import DigitalInOut, Direction, Pull lcd = LCD(I2CPCF8574Interface(0x27), num_rows=2, num_cols=16) #setting up the lcd lcd.set_cursor_pos(0, 0) #where the lcd will start printing button = DigitalInOut(board.D2) #setting the pin for button button.direction = Direction.INPUT button.pull = Pull.UP # switch = DigitalInOut(board.D13) #setting the pin for switch switch.direction = Direction.INPUT switch.pull = Pull.UP counter = 0 #counter starts at zero now = True later = True switchValue = True while True: now = button.value switchValue = switch.value print(str(switchValue)) #print if the switch is up or down if now == False and later == True: if switchValue: #if switch is up count up
import busio import time import digitalio import effects as FX import presets import usb_midi import ui import midi import board from log import log from lcd.lcd import LCD from lcd.i2c_pcf8574_interface import I2CPCF8574Interface from lcd.lcd import CursorMode # Setup LCD lcd = LCD(I2CPCF8574Interface(busio.I2C(scl=board.GP3, sda=board.GP2), 0x27)) lcd.set_cursor_mode(CursorMode.HIDE) # Setup Custom Chars lcd.create_char(0, bytearray([0x00, 0x04, 0x08, 0x1F, 0x08, 0x04, 0x00, 0x00])) # Prev lcd.create_char(1, bytearray([0x00, 0x04, 0x02, 0x1F, 0x02, 0x04, 0x00, 0x00])) # Next lcd.create_char(2, bytearray([0x00, 0x0E, 0x0A, 0x0E, 0x04, 0x06, 0x06, 0x00])) # Key log(str("Set Up Custom Characters")) # Shutdown Function def shutdown(wait): time.sleep(wait)
import board from lcd.lcd import LCD from lcd.i2c_pcf8574_interface import I2CPCF8574Interface from lcd.lcd import CursorMode # Talk to the LCD at I2C address 0x27. # The number of rows and columns defaults to 4x20, so those # arguments could be omitted in this case. lcd = LCD(I2CPCF8574Interface(board.I2C(), 0x27), num_rows=4, num_cols=20) lcd.print("abc ") lcd.print("This is quite long and will wrap onto the next line automatically.") lcd.clear() # Start at the second line, fifth column (numbering from zero). lcd.set_cursor_pos(1, 4) lcd.print("Here I am") # Make the cursor visible as a line. lcd.set_cursor_mode(CursorMode.LINE)
import board#pylint: disable-msg=import-error import digitalio#pylint: disable-msg=import-error from lcd.lcd import LCD#pylint: disable-msg=import-error from lcd.i2c_pcf8574_interface import I2CPCF8574Interface#pylint: disable-msg=import-error btnstate = False#used to see if button is pressed oldbtnstate = False#used to see if button used to pressed(so it only increments once per press) count = 0 lcd = LCD(I2CPCF8574Interface(0x3F), num_rows=2, num_cols=16)#creates an LCD object called "lcd" at adress 0x3F with 2 rows and 16 collumns switch = digitalio.DigitalInOut(board.D12)#create a digitalio object called switch switch.direction = digitalio.Direction.INPUT#set it to input btn = digitalio.DigitalInOut(board.D13) btn.direction = digitalio.Direction.INPUT btn.pull = digitalio.Pull.UP#lets the button use a pull up resistor which means it will read HIGH when not being pressed lcd.set_cursor_pos(0, 0)#moves the cursor to row 0 collumn 0 lcd.print("Button presses:") while True: lcd.set_cursor_pos(1, 0) lcd.print(str(count))#turn integer count into a string, so it can be printed btnstate = btn.value if not btn.value and (btnstate == (not oldbtnstate)):#if button is pressed and it didn't used to be if switch.value:#determines if it counts up or down count += 1#set count equal to count + 1 else: count -= 1 oldbtnstate = btnstate
import board import time import simpleio import analogio from lcd.lcd import LCD from lcd.i2c_pcf8574_interface import I2CPCF8574Interface from lcd.lcd import CursorMode # Talk to the LCD at I2C address 0x27. # The number of rows and columns defaults to 4x20, so those # arguments could be omitted in this case. lcd1 = LCD(I2CPCF8574Interface(board.I2C(), 0x3f), num_rows=2, num_cols=16) lcd2 = LCD(I2CPCF8574Interface(board.I2C(), 0x27), num_rows=2, num_cols=16) posPot = analogio.AnalogIn(board.A1) valPot = analogio.AnalogIn(board.A2) PID = False values = [3.56, 3.56, 1.23, PID] oldValues = [0, 0, 0, 0] kP = 0 kI = 1 kD = 2 pid = 3 def setScreen(): '''Prints out all static messages at once'''
import time import board import busio #A library necessary for LCD screens from digitalio import DigitalInOut, Direction, Pull from lcd.lcd import LCD #Getting the LCD from the lcd library from lcd.lcd import CursorMode #Lets you use cursor mode with the lcd from lcd.i2c_pcf8574_interface import I2CPCF8574Interface #Importing the LCD backpack lcd = LCD(I2CPCF8574Interface(0x27), num_rows=2, num_cols=16) #LCD setup counter = 0 #The counter starts at zero button = DigitalInOut(board.D2) #My button is connected to digital pin 2 button.direction = Direction.INPUT #The button is collecting information, therfore it is an input button.pull = Pull.UP switch = DigitalInOut(board.D8) #My switch is connected to digital pin 8 switch.direction = Direction.INPUT #The switch is also an input switch.pull = Pull.UP lcd.set_cursor_pos(1,0) #Printing SwitchState: in the first spot of the second row lcd.print("SwitchState:") while True: if not button.value and oldButton:#If the button is being pressed, and it has been lifted since the last time it was pressed print("pressed!") #The serial monitor will let me know when the button is pressed lcd.set_cursor_pos(0,0) #Starting in the very first position lcd.print("Presses: ") #The lcd screen will show the number of times the button has been pressed lcd.print(str(counter)) #Printing the number of presses to the lcd lcd.print(" ") #Formatting to make the lcd printing and spacing look right #time.sleep(.05) if switch.value: #If the switch is off