Python Python Idle with Adafruit LCD issues

James Stinson

New Member


Messages: 1

I have created a program to work with Adafruit LCD to work as a newspaper stand and it is suppose to work by using the left, right, and down buttons on the Adafruit LCD as coins inserted. The goal is to reach 30 cents for the machine to "open" so that you can get a paper then the LCD is suppose to display enjoy your paper. I have the program written but the buttons being pressed is not doing anything. Below is the code and any help would be greatly appreciated.

Code:
from time import time
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate

# Adafruit object
LCD_disp = Adafruit_CharLCDPlate()

# declare the required variables
Inp_NICKEL = 5
Inp_DIME = 10
Inp_QUARTER = 25
tot = 0

# method to print the total
def print_total():
  LCD_disp.clear()
  LCD_disp.message(' Total: $.' + str(tot).zfill(2))

def print_change():
LCD_disp.message('Change: $.' + str(tot - 30).zfill(2))

LCD_disp.message("Today’s Paper/nOnly 30 Cents.")
# loop code to continuously process input

while (tot < 30):
# code to represent switches on the Adafruit LCD
  if LCD_disp.buttonPressed(LCD_disp.LEFT):
    tot = tot + Inp_NICKEL
    print_total()
  if LCD_disp.buttonPressed(LCD_disp.RIGHT):
    tot = tot + Inp_DIME
    print_total()
  if LCD_disp.buttonPressed(LCD_disp.DOWN):
    tot = tot + Inp_QUARTER
    print_total()

print_change()
sleep(1) # sleeping for a second

LCD_disp.clear();
LCD_disp.message('Enjoy')
LCD_disp.message('Your Paper')
 
Top