Arduino Programming Part 6: LCD Panel Output ME 121 Portland State University.

Slides:



Advertisements
Similar presentations
Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view class.
Advertisements

Electrical team Arduino tutorial I BY: JOSHUA arduini
Lab7: Introduction to Arduino
ARDUINO FRAMEWORK.
What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University
OOP & JAVA. HelloWorld.java /** * The HelloWorld class is an application that * displays "Hello World!" to the standard output. */ public class HelloWorld.
Classes and Instances. Introduction Classes, Objects, Methods and Instance Variables Declaring a Class with a Method and Instantiating an Object of a.
Writing Methods. Create the method Methods, like functions, do something They contain the code that performs the job Methods have two parts.
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.
Embedded Programming and Robotics Lesson 9 Keypad and LCD Display 1.
Parallax 4x20 LCD (part number 27979) with Arduino Duemilanove
Arduino Part 2 Topics: Serial Communication Programming Constructs: functions, loops and conditionals Digital Input.
Digital Outputs LCD Display
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Introduction to Object Oriented Design. Topics Designing Your Own Classes Attributes and Behaviors Class Diagrams.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Week 3 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Programming Hexors on Arduino Uno. Arduino Uno Arduino is an open-source electronics platform based on easy- to-use hardware and software. It's intended.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Practical Electronics & Programming
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
Classes CS 21a: Introduction to Computing I First Semester,
Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics.
Week 1 Algorithmization and Programming Languages.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Classes Representing Non-Trivial Objects. Problem Write a program that reads a temperature (either Fahrenheit or Celsius), and displays that same temperature.
Intro to Programming Web Design ½ Shade Adetoro. Programming Slangs IDE - Integrated Development Environment – the software in which you develop an application.
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
An Introduction to Programming with C++ Sixth Edition Chapter 10 Void Functions.
BM-305 Mikrodenetleyiciler Güz 2015 (10. Sunu) (Yrd. Doç. Dr. Deniz Dal)
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
CLASSES AND OBJECTS Chapter 3 : constructor, Separate files, validating data.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
ME 120: User-defined functions: average analog input reading Arduino Programming – Part 5: User-defined functions ME 120 Mechanical and Materials Engineering.
Fish Tank Project Introduction ME 121Portland State University Mechanical and Materials Engineering.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
:Blink Blink: Er. Sahil Khanna
Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor If you want to swing an robot arm or … steer a robot you need a special motor (Servo).
ME 120: Arduino Programming Arduino Programming Part 1 ME 120 Mechanical and Materials Engineering Portland State University
Wireless control of an LED. the XBee transceiver transmitter: sends radio waves receiver: receives radio waves transceiver: sends AND receives.
Arduino Programming Part 7: Flow charts and Top-down design ME 121 Gerald Recktenwald Portland State University
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.
Using a SparkFun™ serial LCD with an Arduino
Making a 24hr Timer.
Lab 2: Arduino Sensors Topics: Arduino Sensor Reading, Display
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
Audio tools with Arduino
CS4101 Introduction to Embedded Systems Lab 10: Tasks and Scheduling
LCD.
UCD ElecSoc Robotics Club 2017/2018
Arduino.
Introduction to Gobbit Programming
Chapter 4: Writing Classes
Roller Coaster Design Project
What is Arduino? By James Tedder.
Writing Methods.
Classes, Encapsulation, Methods and Constructors (Continued)
Introduction to Classes and Objects
Intro to Micro Controllers
CTY SAR FCPS Shawn Lupoli, Elliot Tan
LCD (LIQUID CRISTAL DISPLAY) SCREENS
Arduino程式範例.
CTY SAR FCPS Vedant mathur, Juliana schalkwyk
LCD.
Presentation transcript:

Arduino Programming Part 6: LCD Panel Output ME 121 Portland State University

2 Goals Use the 20x4 character LCD display for output ❖ Overview of assembly — detailed instructions on the web ‣ ‣ ❖ Introduction to the LCD library ‣ ❖ Simple demonstration ❖ Map the 20x4 character display for fish tank data

3 Breadboard connection via the wiring harness

4 Programming Arduino for LCD Display Refer to Adafruit tutorial ❖ and Arduino documentation ❖

5 Test the display // include the library code: #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); } void loop() { // set the cursor to column 0, line 1 // Line 1 is the second row, because counting begins with 0 lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis()/1000); } File Examples LiquidCrystal HelloWorld

// include the library code: #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); } void loop() { // set the cursor to column 0, line 1 // Line 1 is the second row, because counting begins with 0 lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis()/1000); } 6 Test the display File Examples LiquidCrystal HelloWorld Change pin assignments to match wiring harness: (8,9,10,11,12,13) Change pin assignments to match wiring harness: (8,9,10,11,12,13) Change to (20,4)

// include the library code: #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); } void loop() { // set the cursor to column 0, line 1 // Line 1 is the second row, because counting begins with 0 lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis()/1000); } 7 Test the display File Examples LiquidCrystal HelloWorld lcd is a LiquidCrystal object

8 Arduino code to write to the LCD panel Include the LCD library Initialize the display by creating a LiquidCrystal object Send characters in a two-step process Move the cursor:lcd.setCursor(column,row) Display the message:lcd. print(“message”) In the header: (outside and before setup) #include Before using the display:LiquidCrystal lcd(p1,p2,p3,p4,p5,p6); lcd.begin(20,4);

9 Row and column indices begin with zero Character matrix on a 4 X 20 display

10 Character matrix on a 4 X 20 display Row and column indices begin with zero

11 Display fish tank salinity Modify the HelloWorld code to display the salinity ❖ “Salinity = ” and “Average of ” can be displayed once at the start ❖ x.xx and NNN values change, and are updated on the display.

12 Create a new LiquidCrystal object: When a new object is created, the data passed to the constructor is stored in the object. Thus, whenever we use the variable lcd again in the program, the lcd object “knows” that it is connected to p1, p2,..., p6. LCD library code LiquidCrystal lcd(p1,p2,p3,p4,p5,p6); Type of objectName of the new object Data passed to the object constructor

13 Tell the lcd object about the size of the display Objects have data and methods ❖ Data are values associated with a particular “instance” of an object ❖ Some data may be “public”. Programmers can view or change public data. ❖ Some data may be “private”, and therefore unavailable to programmers. ❖ Methods are functions that an object knows how to perform ‣ Methods can return values ‣ Methods can change public data ‣ Methods can perform computations and interact with the environment (sensors) LCD library code lcd.begin(20,4) Run the “begin” methodPass the values 20 and 4 to the “begin” method

14 Change the current cursor position: The setCursor methods prepares lcd for its next action lcd.print(...) works because the lcd object “knows” about its current position (from setCursor), the size of the display (from begin), and from the pin assignments from the constructor. When the lcd.print() method runs, it unleashes action that is constrained by data stored in the object. LCD library code lcd.setCursor(12,1) Run the “setCursor” methodPass 12 and 1 to the “setCursor” method lcd.print(“Hello”) Run the “print” methodUse “Hello” as data for the print method