element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum How do I add a Liquid Crystal Display to my current project
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 37 replies
  • Answers 2 answers
  • Subscribers 403 subscribers
  • Views 3555 views
  • Users 0 members are here
  • x
  • 1
  • lcd_display
  • arduino
  • 16
Related

How do I add a Liquid Crystal Display to my current project

Former Member
Former Member over 12 years ago

Hello,

 

I recently completed, with some assistance from Coder27, Bill Abbot, Tony, and Mark Beckett the first part of my project ( http://www.element14.com/community/thread/23967?start=0&tstart=0 )

Now the second part - I am wanting to add a small 16 x 1 LCD to finish up my project (see coding below that I will be using)

I would like the LCD to simply show which direction a servo is pointing (as in degrees, such as 0°, 90°, 180°, 270°, or 360° or anywhere in between 0° to 360°)

Please be advised: I do know that arduino 1.0.4 has the LCD Scroll example, but I am sure I dont need the entire code they have.  Also, my LCD is only 16 x 1, not x 2.

Thanks,

~Anna

 

******** BEGINNING OF CODE *************

#include <Servo.h>

 

const int pan1 = 3;     // first servo

const int tilt1 = 5;    // second servo

const int pan2 = 9;     // third servo

const int tilt2 = 11;    // fourth servo

 

const int potpan1 = A0; // Joystick 1 Vertical signal

int val0;

const int pottilt1 = A1;   // Joystick 1 Horizontal signal

int val1;

const int potpan2 = A5;   // Joystick 1 Select signal

int val2;

const int pottilt2= A3;   // Joystick 2 Vertical signal

int val3;

 

int servoVal[4];        // variable to read the value from the analog pin

 

Servo mypan1;                                  // create servo object to control a servo

Servo mytilt1;    // create servo object to control a servo

Servo mypan2;                                  // create servo object to control a servo

Servo mytilt2;    // create servo object to control a servo

 

void setup()

{

 

  // Servo 

  mypan1.attach(pan1);  // attaches the servo

  mytilt1.attach(tilt1);  // attaches the servo

  mypan2.attach(pan2);  // attaches the servo

  mytilt2.attach(tilt2);  // attaches the servo

 

  // Inizialize Serial

  Serial.begin(57600);

}

 

void loop()

{

 

  outputPotentiometers();           // Read and output joystick values

 

  val0 = analogRead(potpan1);            // reads the value of the potentiometer (value between 0 and 1023)

  val0 = map(val0, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)

  mypan1.write(val0);                  // sets the servo position according to the scaled value

 

  //Serial.print("Value of PWM 3:   ");

  //Serial.println(val0);

  //Serial.print("\t");

 

  val1 = analogRead(pottilt1);            // i added

  val1 = map(val1, 0, 1023, 0, 179);     // i added

  mytilt1.write(val1);                  // i added 

 

  //Serial.print("Value of PWM 5:   ");

  //Serial.println(val1);

  //Serial.print("\t");

 

  val2 = analogRead(potpan2);            // i added

  val2 = map(val2, 0, 1023, 0, 179);     // i added

  mypan2.write(val2);                  // i added

 

  //Serial.print("Value of PWM 6:   ");

  //Serial.println(val2);

  //Serial.print("\t");

 

 

  val3 = analogRead(pottilt2);            // i added

  val3 = map(val3, 0, 1023, 0, 179);     // i added

  mytilt2.write(val3);                  // i added

 

  delay(20);                                      

}

 

void outputPotentiometers()     // Display Joystick Values

{

  Serial.print("Pot Pan 1 on ~3:     ");

  Serial.print(analogRead(potpan1));

  Serial.print("\t");

  Serial.print("     Pot Tilt 1 on ~5:     ");

  Serial.print(analogRead(pottilt1));

  Serial.print("\t");

  Serial.print("     Pot Pan 2 on ~9:     ");

  Serial.print(analogRead(potpan2));

  Serial.print("\t");

  Serial.print("     Pot Tilt 2 on ~11:     ");

  Serial.println(analogRead(pottilt2));

  Serial.print("\t");

 

}

 

 

 

********** END OF CODE *************

  • Sign in to reply
  • Cancel

Top Replies

  • ntewinkel
    ntewinkel over 12 years ago +1 suggested
    Here's a good example to start with: http://arduino.cc/en/Tutorial/LiquidCrystal You'd have to change the setup line to be lcd.begin(16,1) for your smaller display (and assuming the lcd lib supports it…
  • mcb1
    mcb1 over 12 years ago in reply to billabott +1 verified
    Annasta Your explanation does give us some clues where your learnng lies, and how you have come to be involved, so thanks. You may have noticed that there are many people asking for help, and a lot are…
  • Former Member
    Former Member over 12 years ago in reply to billabott +1
    If I might add a bit to WATB's reply, we get all sorts of questions here, and the kind of answer you want to give differs based on the motivation for the question. If someone is asking for help with what…
Parents
  • ntewinkel
    0 ntewinkel over 12 years ago

    Here's a good example to start with: http://arduino.cc/en/Tutorial/LiquidCrystal

     

    You'd have to change the setup line to be lcd.begin(16,1) for your smaller display (and assuming the lcd lib supports it).

     

    The trickiest part (other than hooking up all the wires) might just be to try and fit all your information into 16 characters image

     

    Cheers,

    -Nico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • ntewinkel
    0 ntewinkel over 12 years ago

    Here's a good example to start with: http://arduino.cc/en/Tutorial/LiquidCrystal

     

    You'd have to change the setup line to be lcd.begin(16,1) for your smaller display (and assuming the lcd lib supports it).

     

    The trickiest part (other than hooking up all the wires) might just be to try and fit all your information into 16 characters image

     

    Cheers,

    -Nico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • mcb1
    0 mcb1 over 12 years ago in reply to ntewinkel

    Annasta

     

    You can scroll just part of the display.

    Here is a link here to doing that with enough comments to allow you to work it out.

    http://digistump.com/board/index.php/topic,529.0.html

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube