Introduction: CSCI255 LCD Final
Learn to display temperature to an LCD from a MSP430 micro-controller.
Attachments
Step 1: Get the LCD
- Purchase the LCD below, or one similar.
Step 2: Data Sheet
- Use page 4 to connect to your micro-controller and learn the pins.
- Use sample code provided on page 10. We will later edit this to fit our needs
- Use page 9 to learn how to display characters and symbols.
Step 3: Connecting Display to Micro-controller
- Connect Pin 1.1 to CS (Purple)
- Pin 1.2 to RS (Grey)
- Pin 1.3 to BL (Black)
- Pin 1.5 to CLK (Green)
- Pin 1.7 to MOSI (Blue)
- Apply correct voltage (3.3) to VSS (Red)
- Connect ground to VDD (Brown)
Step 4: Declare Variables
While these are the variables we chose, there are many different approaches that can be used.
int adc[10] = {0};
int avg_adc = 0;
volatile int bit;
volatile int i,n, zeroth,first,second;
float temp;
float degF;
float longfirst;
Step 5: Initialize Functions
void adc_Setup();
This function points the ADC to the internal temperature sensor
void adc_Sam10();
Tells the micro-controller to continuously sample ADC
void Initialize();
Initializes the LCD to the desired settings
void Writecom();
Initializes function for future use, also sets the cursor on LCD
void Writedata();
Initializes function for future use
void Temperature();
Prints the word "Temperature" on the top row, also used to print character value to LCD
Step 6: Write Setup Functions
- Enable the ADC interrupt service routine
- Setup the ADC interrupt and point to internal temperature sensor
- Set the ADC sampling
- Initialize the LCD
Step 7: Write the LCD Communication Function
- Set CS and RS pins low
- Send the Most Significant Bit (MSB) to LCD through pin 1.7
- Shift one bit left
- Send a low, high, and low clock signal
- Repeat steps 1-4 (MSB will shift each time)
- After 8 bits are sent, set CS high, and return to where function was called
- This function is used to set cursor and other settings for LCD
Step 8: Write Data to LCD
Set CS low and RS high
The rest will be the same as function described in Step 7
This function is used to write characters to the LCD display
Step 9: Write a Function to Display Temperature
- Create a character array of integers(0-9) used to convert integers to ASCII
- Use Writecom function to set cursor to top left
- Use Writedata to print "Temperature" one character at a time
- Move cursor to second row using Writecom
- Calculate value of the three individual characters
- Use Writedata to display the characters one at a time
- Use Writedata to display °F
Step 10: Write Main Function
- Stop Watch Dog Timer
- Initialize MSP430 I/O pins
- Call the initializing functions
- Create forever loop
- Turn LCD back light on
- Call ADC sampling function
- Calculate temperature using ADC
- Call temperature display function
- Insert an optional delay to slow sample and display rate