""" Author: Tobias Müller Date: 30.06.2023 Version: 1.0 Main File to run on the pico. """ ############################## Modules ############################## from Libs.LCD_Shield import LCD from time import sleep_us from machine import Pin ############################## Global Variables ############################## Display = LCD() ############################## Main ############################## def main(): """ Main Program """ ########################## Local Variables ############################ button_up = Pin(6,Pin.IN,Pin.PULL_DOWN) button_down = Pin(7,Pin.IN,Pin.PULL_DOWN) button_right = Pin(8,Pin.IN,Pin.PULL_DOWN) button_left = Pin(9,Pin.IN,Pin.PULL_DOWN) led_green = Pin(16,Pin.OUT) led_red = Pin(17,Pin.OUT) ########################## Code ############################ led_green.off() led_red.off() Display.lcd_line_mode = LCD.TWO_LINES Display.print("Hochschule Anhalt") for _ in range(0,3): for brightness in range(0,105,5): Display.lcd_brightness = brightness sleep_us(25000) for brightness in range(0,105,5): Display.lcd_brightness = 100 - brightness sleep_us(20000) Display.clear() Display.print("LCD Shield testing:") for brightness in range(0,105,5): Display.lcd_brightness = brightness sleep_us(20000) sleep_us(2000000) while True: if button_up.value(): Display.clear() Display.lcd_line_mode = LCD.FOUR_LINES Display.print("button", row=1) Display.print("up *", row=2) Display.print("* *", row=3, column=7) Display.print("*", row=4, column=8) led_red.on() sleep_us(300000) Display.clear(row=2, column=8) led_red.off() sleep_us(300000) elif button_down.value(): Display.clear() Display.lcd_line_mode = LCD.FOUR_LINES Display.print("button down * * * *") led_green.on() sleep_us(300000) Display.clear(row=4) led_green.off() sleep_us(300000) elif button_left.value(): Display.clear() Display.lcd_line_mode = LCD.FOUR_LINES Display.print("button", row=1) Display.print("left *", row=2) Display.print("* *", row=3, column=7) Display.print("*", row=4, column=8) led_green.off() led_red.on() sleep_us(300000) Display.clear(row=3, column=7) led_green.on() led_red.off() sleep_us(300000) elif button_right.value(): Display.clear() Display.lcd_line_mode = LCD.FOUR_LINES Display.print("button\nright *\n * *\n *") led_green.on() led_red.on() sleep_us(300000) Display.clear(row=3, column=9) led_green.off() led_red.off() sleep_us(300000) else: Display.clear() Display.lcd_line_mode = LCD.THREE_LINES_MIDDLE led_red.off() led_green.off() Display.print("LCD Shield") Display.print("a button", row=3, column=2) for pattern in range(0,9): if pattern == 0: Display.print(" push ", row=2) elif pattern == 1: Display.print("> push <", row=2) elif pattern == 2: Display.print(">> push <<", row=2) elif pattern == 3: Display.print(">>>push<<<", row=2) elif pattern == 4: Display.print(" >>push<< ", row=2) elif pattern == 5: Display.print(" >push< ", row=2) elif pattern == 6: Display.print(" push ", row=2) else: Display.clear(row=2) sleep_us(100000) ############################## Run ############################## if __name__ == "__main__": main()