Using a SparkFun™ serial LCD with an Arduino

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Advertisements

Lab7: Introduction to Arduino
ARDUINO FRAMEWORK.
How to use Arduino By: Andrew Hoffmaster.
Embedded Sumo 1T4 – 1T5 UTRA.
Using the Arduino to Make an LED Flash Work in teams of two! living with the lab digital I/O pins (I/O = input / output) USB cable plug power pins.
1 Introduction to Coding. 2 Example Codes A lot of example codes are given with Arduino IDE A code can often be based on a previous example rather than.
Parallax 4x20 LCD (part number 27979) with Arduino Duemilanove
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
Digital Outputs LCD Display
Thermistor calibration living with the lab © 2013 David Hall.
Practical Electronics & Programming
Introduction to the Arduino
1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium.
CS-280 Dr. Mark L. Hornick 1 Programming for the LCD Display.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
Microcontrollers, Microcomputers, and Microprocessors
Arduino libraries Datatekniker Udvidet hardware/software.
Basic Circuits – Lab 5 Wireless Networking Xmedia Spring 2011.
ME 120: Arduino Programming Arduino Programming Part II ME 120 Mechanical and Materials Engineering Portland State University
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
:Blink Blink: Er. Sahil Khanna
Microcontroller basics
1 Introduction to Coding. 2 Example Codes A lot of example codes are given with Arduino IDE A code can often be based on a previous example rather than.
Having fun with code, using Arduino in a middle school CS classroom
Making a 24hr Timer.
Application of Programming: Scratch & Arduino
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
simple example program to control a DC-Motor
Prototyping with Microcontrollers and Sensors
Val Manes Department of Math & Computer Science
CS4101 Introduction to Embedded Systems Lab 10: Tasks and Scheduling
Manual for Arduino Kit v1.0
Introduction to the Arduino
Arduino Programming Part II
UTA010 : Engineering Design – II
An Arduino Workshop A Microcontroller.
calibration of conductivity sensors
Welcome to Arduino A Microcontroller.
Get Your Project Started with Arduino
Servo Library and Functions
LCD.
UCD ElecSoc Robotics Club 2017/2018
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
Arduino.
3.1 Serial Communication Part 1
Roller Coaster Design Project
EET 2261 Unit 11 Controlling LCD and Keypad
ARDUINO     What is an Arduino? Features 14 Digital I/O pins 6 Analogue inputs 6 PWM pins USB serial 16MHz Clock speed 32KB Flash memory 2KB SRAM.
Maxbotix Ultrasonic Distance Sensor
Schedule 8:00-11:00 Workshop: Arduino Fundamentals
Servo Library and Functions
EET 2261 Unit 11 Controlling LCD and Keypad
Arduino 101 Credit(s):
using the Arduino to make LEDs flash
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Welcome to Digital Electronics using the Arduino Board
Arduino: For Loops.
Arduino Part 4 Let there be more light.
Intro to Micro Controllers
CTY SAR FCPS Shawn Lupoli, Elliot Tan
CTY SAR FCPS Shawn Lupoli, Elliot Tan
LCD (LIQUID CRISTAL DISPLAY) SCREENS
Arduino 7 Segment Display Lab
Aeroponic Engineering and Vertical Farming
Arduino Uno circuit basics
Setting up a basic program with Arduino
LCD.
Presentation transcript:

Using a SparkFun™ serial LCD with an Arduino living with the lab Using a SparkFun™ serial LCD with an Arduino SparkFun Serial Enabled 20x4 LCD (part number: LCD-09568) with Arduino Uno

Transmits serial data from digital I/O pin to LCD (plugged into Pin 2) living with the lab LCD wiring back view RX = Receives serial data from Arduino GND = ground wire 5V = power wire Transmits serial data from digital I/O pin to LCD (plugged into Pin 2) Ground 5V Power front view

LCD and Arduino together living with the lab LCD and Arduino together

Programming living with the lab Text: “Louisiana Tech University” is displayed, with character locations chosen to center the text on the first two lines of the LCD Integers: The text “i=“ is printed followed by an integer that varies from 1 to 10 Floating Point Numbers: The text “x=“ is printed followed by a number with four numerals printed to the right of the decimal; the value here ranges from 0.0010 to 0.0100

Cursor Position & Printing to the 20x4 LCD living with the lab Cursor Position & Printing to the 20x4 LCD Row: 1 Column: 5 mySerial.write(197); // move cursor to row 1, position 5 mySerial.write("University"); // print a text string starting at (1,5) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231

A Complete Sample Sketch See the Parallax website (www.parallax.com) for more details. Custom characters and other features are available for this LCD. When developing your sketch, print things to the LCD screen only once if they do not change. For example, the text in this sketch is printed once in setup(), while the variables are printed repeatedly in loop(). A Complete Sample Sketch living with the lab /*****************************************************************************/ /* Example program using a Sparkfun 4x20 LCD to output text and numbers. */ /* The following screen is printed: */ /* --------------------- */ /* | Louisiana Tech | */ /* | University | */ /* | | */ /* | i=8 x=0.0080 | where 1<=i<=10 and 0.0000<=x<=0.0100 */ /* The program prints out both integers and floating point numbers. The */ /* floating point number is printed to four decimal places. */ /* */ /* A partial listing of commands recognized by the LCD is provided below. */ /* See the data sheet for the LCD on the Parallax web site for more details. */ /* mySerial.write(254) - control command must be sent before commands below */ /* mySerial.write(1) - clear display and move cursor to top left */ /* mySerial.write(8) - turn display off */ /* mySerial.write(12) - turn display on / hide cursor */ /* mySerial.write(13) - blinking cursor on */ /* mySerial.write(14) - underline cursor on */ /* mySerial.write(16) - move cursor left one space */ /* mySerial.write(20) - move cursor right one space */ /* mySerial.write(24) - scroll left one space */ /* mySerial.write(28) - scroll right one space */ /* mySerial.write(124) - control command must be sent before commands below */ /* mySerial.write(128) - backlight off */ /* mySerial.write(157) - backlight fully on */ /* row and position commands are shown below for all 80 character positions */ /* ROW 0: 128=(0,0) 129=(0,1) 130=(0,2) 131=(0,3) 132=(0,4) */ /* 133=(0,5) 134=(0,6) 135=(0,7) 136=(0,8) 137=(0,9) */ /* 138=(0,10) 139=(0,11) 140=(0,12) 141=(0,13) 142=(0,14) */ /* 143=(0,15) 144=(0,16) 145=(0,17) 146=(0,18) 147=(0,19) */ /* ROW 1: 192=(2,0) 193=(2,1) 194=(2,2) 195=(2,3) 196=(2,4) */ /* 197=(2,5) 198=(2,6) 199=(2,7) 200=(2,8) 201=(2,9) */ /* 202=(2,10) 203=(2,11) 204=(2,12) 205=(2,13) 206=(2,14) */ /* 207=(2,15) 208=(2,16) 209=(2,17) 210=(2,18) 211=(2,19) */ /* ROW 2: 148=(1,0) 149=(1,1) 150=(1,2) 151=(1,3) 152=(1,4) */ /* 153=(1,5) 154=(1,6) 155=(1,7) 156=(1,8) 157=(1,9) */ /* 158=(1,10) 159=(1,11) 160=(1,12) 161=(1,13) 162=(1,14) */ /* 163=(1,15) 164=(1,16) 165=(1,17) 166=(1,18) 167=(1,19) */ /* ROW 3: 212=(3,0) 213=(3,1) 214=(3,2) 215=(3,3) 216=(3,4) */ /* 217=(3,5) 218=(3,6) 219=(3,7) 220=(3,8) 221=(3,9) */ /* 222=(3,10) 223=(3,11) 224=(3,12) 225=(3,13) 226=(3,14) */ /* 227=(3,15) 228=(3,16) 229=(3,17) 230=(3,18) 231=(3,19) */ /* To print variables to the LCD, you need to use the mySerial.print() */ /* command instead of the mySerial.write() command. For example, the command */ /* mySerial.print(x,4) will send variable "x" to the LCD with four digits */ /* beyond the decimal point. */ /* Note that you may need to unplug the ground wire to the LCD and reset */ /* the Arduino after uploading sketch to make it display correctly. */ #include <SoftwareSerial.h> // use the software serial library SoftwareSerial mySerial(3,2); // receive data at pin 3; transmit data at pin 2 void setup() { mySerial.begin(9600); delay(500); // set data rate to 9600 baud; wait for bootup mySerial.write(254); mySerial.write(1); // clear screen & move to top left position mySerial.write(254); mySerial.write(131); // move cursor to row 0, position 3 mySerial.write("Louisiana Tech"); // write a text string starting at (0,3) mySerial.write(254); mySerial.write(197); // move cursor to row 1, position 5 mySerial.write("University"); // write a text string starting at (1,5) mySerial.write(254); mySerial.write(212); // move cursor to row 3, position 0 mySerial.write("i= x="); // write text string at (3,0) } void loop() { float x=0.0; for (int i=1;i<=10;i++) { x=x+0.0010; // add 0.001 to variable x mySerial.write(254); mySerial.write(216); // move cursor to row 3, position 4 mySerial.print(i); // print i at the current cursor position mySerial.write(" "); // write blanks to cover previous printing mySerial.write(254); mySerial.write(224); // move cursor to row 3, position 12 mySerial.print(x,4); // print x to 4 decimal places delay(1000); // delay 1 second between printing numbers

Looking at Sections of the Sketch See the Parallax website (www.parallax.com) for more details. Custom characters and other features are available for this LCD. When developing your sketch, print things to the LCD screen only once if they do not change. For example, the text in this sketch is printed once in setup(), while the variables are printed repeatedly in loop(). Looking at Sections of the Sketch living with the lab /*****************************************************************************/ /* Example program using a Sparkfun 4x20 LCD to output text and numbers. */ /* The following screen is printed: */ /* */ /* --------------------- */ /* | Louisiana Tech | */ /* | University | */ /* | | */ /* | i=8 x=0.0080 | where 1<=i<=10 and 0.0000<=x<=0.0100 */ /* The program prints out both integers and floating point numbers. The */ /* floating point number is printed to four decimal places. */ /* A partial listing of commands recognized by the LCD is provided below. */ /* See the data sheet for the LCD on the Parallax web site for more details. */ /* mySerial.write(254) - control command must be sent before commands below */ /* mySerial.write(1) - clear display and move cursor to top left */ /* mySerial.write(8) - turn display off */ /* mySerial.write(12) - turn display on / hide cursor */ /* mySerial.write(13) - blinking cursor on */ /* mySerial.write(14) - underline cursor on */ /* mySerial.write(16) - move cursor left one space */ /* mySerial.write(20) - move cursor right one space */ /* mySerial.write(24) - scroll left one space */ /* mySerial.write(28) - scroll right one space */ /* mySerial.write(124) - control command must be sent before commands below */ /* mySerial.write(128) - backlight off */ /* mySerial.write(157) - backlight fully on */ Explains what sketch is expected to do Control Command that must be written before any LCD programming commands. Commands for programming the LCD Control Command that must be written before any LCD backlight programming commands. Commands for programming the LCD backlight Sketch Continues on Next Slide #include <SoftwareSerial.h> // use the software serial library SoftwareSerial mySerial(3,2); // receive data at pin 3; transmit data at pin 2 void setup() { mySerial.begin(9600); delay(500); // set data rate to 9600 baud; wait for bootup mySerial.write(254); mySerial.write(1); // clear screen & move to top left position mySerial.write(254); mySerial.write(131); // move cursor to row 1, position 2 mySerial.print("Louisiana Tech"); // print a text string starting at (0,3) mySerial.write(254); mySerial.write(197); // move cursor to row 1, position 5 mySerial.write("University"); // print a text string starting at (1,5) mySerial.write(254); mySerial.write(212); // move cursor to row 1, position 5 mySerial.write("i= x="); // print text string at (3,2) } void loop() { float x=0.0; for (int i=1;i<=10;i++) { x=x+0.0010; // add 0.001 to variable x mySerial.write(254); mySerial.write(216); // move cursor to row 3, position 4 mySerial.print(i); // print i at the current cursor position mySerial.write(" "); // print blanks to cover previous printing mySerial.write(254); mySerial.write(224); // move cursor to row 3, position 12 mySerial.print(x,4); // print x to 4 decimal places delay(1000); // delay 1 second between printing numbers

Sketch Continues on Next Slide See the Parallax website (www.parallax.com) for more details. Custom characters and other features are available for this LCD. When developing your sketch, print things to the LCD screen only once if they do not change. For example, the text in this sketch is printed once in setup(), while the variables are printed repeatedly in loop(). living with the lab Provides a list of command values for each cursor position on the LCD screen /* */ /* row and position commands are shown below for all 80 character positions */ /* ROW 0: 128=(0,0) 129=(0,1) 130=(0,2) 131=(0,3) 132=(0,4) */ /* 133=(0,5) 134=(0,6) 135=(0,7) 136=(0,8) 137=(0,9) */ /* 138=(0,10) 139=(0,11) 140=(0,12) 141=(0,13) 142=(0,14) */ /* 143=(0,15) 144=(0,16) 145=(0,17) 146=(0,18) 147=(0,19) */ /* ROW 1: 192=(2,0) 193=(2,1) 194=(2,2) 195=(2,3) 196=(2,4) */ /* 197=(2,5) 198=(2,6) 199=(2,7) 200=(2,8) 201=(2,9) */ /* 202=(2,10) 203=(2,11) 204=(2,12) 205=(2,13) 206=(2,14) */ /* 207=(2,15) 208=(2,16) 209=(2,17) 210=(2,18) 211=(2,19) */ /* ROW 2: 148=(1,0) 149=(1,1) 150=(1,2) 151=(1,3) 152=(1,4) */ /* 153=(1,5) 154=(1,6) 155=(1,7) 156=(1,8) 157=(1,9) */ /* 158=(1,10) 159=(1,11) 160=(1,12) 161=(1,13) 162=(1,14) */ /* 163=(1,15) 164=(1,16) 165=(1,17) 166=(1,18) 167=(1,19) */ /* ROW 3: 212=(3,0) 213=(3,1) 214=(3,2) 215=(3,3) 216=(3,4) */ /* 217=(3,5) 218=(3,6) 219=(3,7) 220=(3,8) 221=(3,9) */ /* 222=(3,10) 223=(3,11) 224=(3,12) 225=(3,13) 226=(3,14) */ /* 227=(3,15) 228=(3,16) 229=(3,17) 230=(3,18) 231=(3,19) */ /* To print variables to the LCD, you need to use the mySerial.print() */ /* command instead of the mySerial.write() command. For example, the command */ /* mySerial.print(x,4) will send variable "x" to the LCD with four digits */ /* beyond the decimal point. */ /* Note that you may need to unplug the ground wire to the LCD and reset */ /* the Arduino after uploading sketch to make it display correctly. */ /*****************************************************************************/ mySerial.print() is used instead of mySerial.write() when you are trying to display variables on the LCD. For example, to display “Tech” on the LCD you would use mySerial.write(), but if you wanted to display an integer that increases by one each iteration, you would used mySerial.print(). Sketch Continues on Next Slide

Library used for LCD & setting pins to recieve/transmit living with the lab Library used for LCD & setting pins to recieve/transmit #include <SoftwareSerial.h> // use the software serial library SoftwareSerial mySerial(3,2); // receive data at pin 3; transmit data at pin 2 void setup() { mySerial.begin(9600); delay(500); // set data rate to 9600 baud; wait for bootup mySerial.write(254); mySerial.write(1); // clear screen & move to top left position mySerial.write(254); mySerial.write(131); // move cursor to row 0, position 3 mySerial.write("Louisiana Tech"); // write a text string starting at (0,3) mySerial.write(254); mySerial.write(197); // move cursor to row 1, position 5 mySerial.write("University"); // write a text string starting at (1,5) mySerial.write(254); mySerial.write(212); // move cursor to row 3, position 0 mySerial.write("i= x="); // write text string at (3,0) } void loop() { float x=0.0; for (int i=1;i<=10;i++) { x=x+0.0010; // add 0.001 to variable x mySerial.write(254); mySerial.write(216); // move cursor to row 3, position 4 mySerial.print(i); // print i at the current cursor position mySerial.write(" "); // write blanks to cover previous printing mySerial.write(254); mySerial.write(224); // move cursor to row 3, position 12 mySerial.print(x,4); // print x to 4 decimal places delay(1000); // delay 1 second between printing numbers Control Command that must be written before LCD display commands Set baud rate for LCD (related to speed of data transmissions) Tells the cursor which position LCD to go to Text strings use mySerial.write() with text in “ ”. Command changed from mySerial.write() to mySerial.print() because displaying variable values NOTE: When developing your sketch, print things to the LCD screen only once if they do not change. For example, the text in this sketch is printed once in setup(), while the variables are printed repeatedly in loop(). See the SparkFun™ website (https://www.sparkfun.com) for more details. Custom characters and other features are available for this LCD.

living with the lab After downloading your sketch, you may need to press the Arduino reset button to remove “gibberish” that may be printed on the LCD. reset button