CLOCK PROJECT

In this project you will learn how to wire and program an LCD alarm clock using Python.

Gather the following materials:

•1x 10 k Ω resistor

•2x 1 kΩ resistor

•1x Adafruit T

-Cobbler (Plus)

•1x Push button

•1x Active Buzzer

•1x S8050 Transistor

•1x Adafruit LCD1602 (with I2C backpack)

•OPTIONAL: 1x Toggle (Changeover) Switch



Activities

diagram to the right, create the circuit:

Please see image on the right.

On the T-Cobbler Plus, GPIO2 and GPIO3 correspond to SDA and SCL respectively.

The grounds in the circuit diagram can be directly hooked into any GND on the T-Cobbler.

The Toggle/ Changeover switch is optional, but nice to have to stop the LCD from being consistently on.

On the backpack, there is a little blue knob to adjust the brightness if the LCD is not lighting up blue and white when given power.


1.       Setup your Raspberry Pi to read the LCD and GPIO:

sudo apt-get install python-smbus i2c-tools


We then need to enable I2C. To do so, go to the Raspberry Pi Configuration by going to:

Raspberry Pi Menu -> Preferences -> Raspberry Pi Configuration

Click the Enable I2C button in the Interfaces tab.




Restart your Raspberry Pi.

Power up your LCD display and run this command in the terminal to check the LCD-I2C memory address (Replace the 1 with a 0 if you have an older Raspberry Pi):

sudo i2cdetect -y 1

 



The display should be similar to below, where the number corresponds to the LCD-I2C memory address (this one is 0x27), which is specified within our program in Display.py’s PCF8574_address or PCF8574A_address. Ensure the table is 27 or 3F, otherwise, remember this value to put into Display.py


Discussion:

o   Reciprocally, if we wanted the buzzer to ring for longer, what would we need to change?

o   When the Pi tells the LCD to move the cursor, is the command stored in the memory or the register?

o   When the Pi is storing the next message to be displayed, is that stored in the memory or the register?


Extended Learning: 

Code for writing to an LCD I2C display from scratch.


Project created by Patience Lamb.