Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is the my course project that I have to do for my class, this is just to give you the information behind what exactly

Below is the my course project that I have to do for my class, this is just to give you the information behind what exactly I am asking. At the very bottom is the code I have for it, I am looking for some assistance in figuring out exactly why the code is not working correctly ( why it doesn't act like the instructions like the problem statement wants it to) and I am hoping for some adjustments from anyone willing to help. thank you for your time and understanding.

Problem Statement

This project will focus on development of the controller for a newspaper dispenser. The newspaper dispenser will accept nickels, dimes, and quarters. The LCD will display a welcome message to each customer: Todays Paper Only 30 Cents. Each time a coin is inserted, the LCD displays the total amount deposited: Total: $XX. When a minimum of 30 cents is inserted, the program will cycle between two screens. The first screen will indicate the total amount deposited: Total: $XX. This is displayed on the top line and the amount of change available (Change: $XX) is displayed on the second line. The second screen will display Enjoy on the first line and Your Paper on the second line in green backlight.

Depositing coins:

Nickels, dimes, and quarters are represented by the switches on the Adafruit LCD + Keypad as shown below.

Coins

Switch on Adafruit

Nickel

Left

Dime

Right

Quarter

Down

image text in transcribed

If the left button is pressed, a nickel is recorded; if the right button is pressed, the controller records a dime; and if the down button is pressed, a quarter is recorded.

Initial Screen

The initial display will appear as in the figure below.

image text in transcribed

Displaying the Running Total

As soon as the first switch is pressed (coin entered) the LCD displays the total amount entered. If Nickel is pressed, the screen below is displayed. Note the leading zero.

image text in transcribed

The program keeps a running total of the amount entered and displays the total amount deposited after each switch is pressed (coin is entered). If Dime is now pressed, the LCD will show the screen below.

image text in transcribed

This process continues until the minimum amount of 30 cents is entered.

Displaying the Total and Change

The focus of this portion of the project is to count and display the change amount that would be refunded along with the total amount inserted. The change amount is displayed on the bottom row of the LCD. Keep in mind the price of the newspaper is 30 cents. The display must look like the following.

image text in transcribed

Develop Door Open Indication Function

When the adequate change has been entered, the Total and Change screen is displayed for 1 second and the message reading Enjoy Your Paper is displayed for 1 second (with a green backlight0. The display must look like the following.

image text in transcribed

The program returns to the beginning and displays the initial screen.

MY CODE:

#!/usr/bin/python

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: $.')

LCD_disp.message(tot)

# loop code to continuously process input

while (tot

# code to represent switches on the Adafruit LCD

LCD_disp.message("Todays PaperOnly 30 Cents.")

if LCD_disp.buttonPressed(LCD_disp.LEFT):

tot = tot + Inp_NICKEL

print_total()

sleep(1)

if LCD_disp.buttonPressed(LCD_disp.RIGHT):

tot = tot + Inp_DIME

print_total()

sleep(1)

if LCD_disp.buttonPressed(LCD_disp.DOWN):

tot = tot + Inp_QUARTER

print_total()

sleep(1)

LCD_disp.message('Enjoy')

LCD_disp.message('Your Paper')

Adafruit i2c 16x2 RGB LCD Pi Plate Contrast SELECTn Nickel Quarter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How many subsets does the set {1, 3, 5, , 99} have?

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago