Arduino Programming Part6 - Computer Action Team

3y ago
43 Views
2 Downloads
2.37 MB
10 Pages
Last View : 20d ago
Last Download : 3m ago
Upload by : Warren Adams
Transcription

Arduino ProgrammingPart 6: LCD Panel OutputEAS 199B, Winter 2013Gerald RecktenwaldPortland State Universitygerry@me.pdx.eduGoalsUse the 20x4 character LCD display for output Overview of assembly — detailed instructions on the web‣ http://web.cecs.pdx.edu/ eas199/B/howto/LCDwiring/‣ http://www.ladyada.net/learn/lcd/charlcd.html Introduction to the LCD library Simple demonstrationMap the 20x4 character display for fish tank data‣ http://www.arduino.cc/en/Tutorial/LiquidCrystal Arduino Programming Part 6: EAS 199B2Breadboard connection via Adafruit Tutorial*!!"!"# %%&'"()*' ,)- ."())!!"0 %%)1232)!"# !!"1/"234567849"&!!"%!!" !!"#!!"!"' "( ##") #") #"* #!"* %!", #,"#! ,"/ (')Arduino Programming Part 6: EAS 199Bhttp://www.ladyada.net/learn/lcd/charlcd.html3

The Adafruit kit1. Header forelectricalconnections2. Potentiometer forcontrast adjustment3. Panel on PCBArduino Programming Part 6: EAS 199B4Wiring nRedYellowBrownGreenWhiteGround 5VWiper of 10k potentiometerpin 8Groundpin 9BlueBlackGrayOrangeRedGreenpin 10pin 11pin 12pin 13 5VGround116Arduino Programming Part 6: EAS 199B5Step 1: Solder the headerArduino Programming Part 6: EAS 199B6

Step 2: Assemble the wiring harnessArduino Programming Part 6: EAS 199B7Crimp Connectors: they are small!Arduino Programming Part 6: EAS 199B8Crimp connectors are smallDon’t bother with the male connectors They are fragile when not enclosed in a connector shellJust tin the stranded wirePlease be careful Connectors are not freeSome failed connections are inevitableArduino Programming Part 6: EAS 199B9

Crimp connectors are smallDon’t bother with the male connectors They are fragile when not enclosed in a connector shellJust tin the stranded wirePlease be careful Connectors are not freeSome failed connections are inevitableDo not raid kits for extra connectors! Ask yourinstructor for spares if you need them.Arduino Programming Part 6: EAS 199B10Use jumpers to avoid unnecessary wireConnection to 5V on ArduinoConnection toground on Arduino 5V on pin 2and pin 15Ground onpin 1, pin 5and pin 16Arduino Programming Part 6: EAS 199B11Locate the crimp connector in the toolArduino Programming Part 6: EAS 199B12

Crimp the strain reliefArduino Programming Part 6: EAS 199B13Finished crimping for the female connectorArduino Programming Part 6: EAS 199B14Finished female and male connectorsFemale connector for LCD endMale pins for Arduino endNote: These male pins still need heat shrink toinsulate pins from each other when they areinserted into a breadboard.Arduino Programming Part 6: EAS 199B15

Finished female and male connectorsFemale connector for LCD endMale pins for Arduino endNote: These male pins still need heat shrink toinsulate pins from each other when they areinserted into a breadboard.Arduino Programming Part 6: EAS 199B16Programming Arduino for LCD DisplayRefer to Adafruit tutorial http://www.ladyada.net/learn/lcd/charlcd.htmland Arduino documentation uino Programming Part 6: EAS 199B17Breadboard connection via Adafruit Tutorial*!!"!"# %%&'"()*' ,)- ."())!!"0 %%)1232)!"# !!"1/"234567849"&!!"%!!" !!"#!!"!"' "( ##") #") #"* #!"* %!", #,"#! ,"/ (')Arduino Programming Part 6: EAS 8

Test the display// include the library code:#include LiquidCrystal.h File Examples LiquidCrystal HelloWorld// initialize the library with the numbers of the interface pinsLiquidCrystal 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 0lcd.setCursor(0, 1);// print the number of seconds since reset:lcd.print(millis()/1000);}Arduino Programming Part 6: EAS 199B19Test the display// include the library code:#include LiquidCrystal.h Change pin assignments tomatch wiring harness:(8,9,10,11,12,13)// initialize the library with the numbers of the interface pinsLiquidCrystal lcd(12, 11, 5, 4, 3, 2);void setup() {// set up the LCD's number of columns and rows:lcd.begin(16, 2);Change to (20,4)// 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 0lcd.setCursor(0, 1);// print the number of seconds since reset:lcd.print(millis()/1000);}Arduino Programming Part 6: EAS 199BFile Examples LiquidCrystal HelloWorld20Test the display// include the library code:#include LiquidCrystal.h // initialize the library with the numbers of the interface pinsLiquidCrystal 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!");}lcd is a LiquidCrystal objectvoid loop() {// set the cursor to column 0, line 1// Line 1 is the second row, because counting begins with 0lcd.setCursor(0, 1);// print the number of seconds since reset:lcd.print(millis()/1000);}Arduino Programming Part 6: EAS 199BFile Examples LiquidCrystal HelloWorld21

Arduino code to write to the LCD panelInclude the LCD library#include LiquidCrystal.h In the header:(outside and before setup)Initialize the display by creating a LiquidCrystal objectBefore using the display: LiquidCrystal lcd(p1,p2,p3,p4,p5,p6);lcd.begin(20,4);Send characters in a two-step processMove the cursor:Display the message:lcd.setCursor(column,row)lcd. print(“message”)Arduino Programming Part 6: EAS 199B22Character matrix on a 4 X 20 displayRow and column indices begin with zero012301234567890123456789Arduino Programming Part 6: EAS 199B23Character matrix on a 4 X 20 displayRow and column indices begin with ino Programming Part 6: EAS 199Blcd.setCursor(6,2)24

Display fish tank salinityModify the HelloWorld code to display the salinity “Salinity ” and “Average of ” can be displayed once at the startx.xx and NNN values change, and are updated on the display.012345678901234567890 Salinity x.xx%1 Average of NNN23Arduino Programming Part 6: EAS 199B25Programming ParadigmsTo think about styles of programming, we can organizeprogramming languages into paradigmsParadigmRepresentative LanguagesProcedural or Sequential Fortran, C, BasicObject-orientedC , smalltalkParallel /Concurrentoccam, erlangDataflowLabVIEWFunctionalHaskel, LispScriptingperl, pythonNote that many modern program languages have features ofmore than one paradigmArduino Programming Part 6: EAS 199B26Object-Oriented Programming (OOP)As you might expect, Objects are central to OOP Objects have dataObjects have methods (like functions)Objects can be assembled into other objects.Arduino Programming Uses the object-oriented language C Don’t get carried away with the OOP on Arduino‣ Keep your Arduino programs from becoming too complex‣ Basic structure of code, with setup() and loop() is sequential Libraries for the Serial Monitor and LCD output use OOP‣ Know enough OOP to use existing libraries‣ OOP can be handy when programming with new types of sensorsArduino Programming Part 6: EAS 199B27

OOP in the LCD library codeCreate a new LiquidCrystal object:LiquidCrystal lcd(p1,p2,p3,p4,p5,p6);Type of objectName of the new objectData passed to the object constructorWhen a new object is created, the data passed to theconstructor is stored in the object. Thus, whenever we usethe variable lcd again in the program, the lcd object“knows” that it is connected to p1, p2, ., p6.Arduino Programming Part 6: EAS 199B28OOP in the LCD library codeTell the lcd object about the size of the displaylcd.begin(20,4)Run the “begin” methodPass the values 20 and 4 to the “begin” methodObjects have data and methods Data are values associated with a particular “instance” of an objectSome 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)Arduino Programming Part 6: EAS 199B29OOP in the LCD library codeChange the current cursor position:lcd.setCursor(12,1)Run the “setCursor” methodPass 12 and 1 to the “setCursor” methodThe setCursor methods prepares lcd for its next actionlcd.print(“Hello”)Run the “print” methodUse “Hello” as data for the print methodlcd.print(.) works because the lcd object “knows” about itscurrent position (from setCursor), the size of the display(from begin), and from the pin assignments from theconstructor. When the lcd.print() method runs, it unleashesaction that is constrained by data stored in the object.Arduino Programming Part 6: EAS 199B30

Arduino Programming Part 6: EAS 199B Programming Paradigms To think about styles of programming, we can organize programming languages into paradigms Note that many modern program languages have features of more than one paradigm 26 Paradigm Representative Languages Procedural or Sequential Fortran, C, Basic Object-oriented C , smalltalk

Related Documents:

Arduino Programming Part 6: EAS 199B Finished female and male connectors 16 Female connector for LCD end Male pins for Arduino end Note: These male pins still need heat shrink to insulate pins from each other when they are inserted into a breadboard. Arduino Programming Part 6: EAS 199B Programming Arduino for LCD Display Refer to Adafruit tutorial

Arduino Programming Part 6: EAS 199B Finished female and male connectors 13 Female connector for LCD end Male pins for Arduino end Note: These male pins still need heat shrink to insulate pins from each other when they are inserted into a breadboard. Arduino Programming Part 6: EAS 199B Programming Arduino for LCD Display Refer to Adafruit tutorial

Arduino compatible components. Personal computer running Arduino software Arduino software is free to download and use from: www.arduino.cc Arduino board Such as: Arduino Uno Freetronics Eleven Genuino Uno or any Arduino compatible board that has a standard Arduino UNO header l

arduino-00 -win.zip Recommended Path c:\Program Files\ ( - version #) Step 3: Shortcut Icon Open c:\program files\arduino-00 Right Click Arduino.exe (send to Desktop (create shortcut)) \ ( - version #) Step 4: Plug In Your Arduino Plug your Arduino in: Using the included USB cable, plug your Arduino board into a free USB port. Wait for a box to .

Hence we given interesting top five easy to make Arduino projects with code and library link. Happy learning Arduino 1. Heart Rate Monitor AD8232 Interface Arduino 2. Fingerprint sensor-scanner with Arduino 3. Giving Voice Recognition Ability to Arduino 4. Soil Moisture Sensor and Arduino 5. How to Interface RFID with Arduino?

Arduino programming . These three lectures can be broken down as follows: 1.) Getting Started with Arduino - Outlines basics of Arduino hardware, software, an d robotics programming 2.) Arduino Programming Language - Details sketch structure, programming syntax notes, and pin functionality 3.) Starting Arduino Examples

3. Then, use the Arduino IDE to write code to send to Arduino. Once a code is sent to the Arduino, it lives on the Arduino Uno. Any future edits to that code on the computer will not be sent to the Arduino unless it is manually uploaded to the Arduino Uno. When using the Arduino

French, German, Japanese, and other languages foreign to them. Information about language learning styles and strategies is valid regardless of what the learner’s first language is. Learning styles are the general approaches –for example, global or analytic, auditory or visual –that students use in acquiring a new language or in learning any other subject. These styles are “the overall .