Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino LCD project #24

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions _posts/en/projects/2019-10-01-electronic-arduino-lcd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
---
layout: article
lang: en
parent: electronic-projects
breadcrumb: true
permalink: /en/projects/scratch-projects/lcd-arduino-2019
iainardo marked this conversation as resolved.
Show resolved Hide resolved
ref: 2019-lcd-arduino
title: LCD Arduino
author: fionnc/Iain Campbell
description: How to use an LCD and Arduino to display a message
tags: Arduino, electronic, lcd
code: true
---

## Arduino LCD

This project used a Liquid Crystal display (LCDs) and an arduino to display a message.
LCDs like these are very popular and broadly used in electronics projects as they are good for displaying information like sensors data from your project.


<img class="img-fluid" src="{{'assets/posts/2019-10-01-arduino-lcd/lcd-coderdojo-message.png' | relative_url}}"/>


### Components
* Arduino Board
* LCD Screen (compatible with Hitachi HD44780 driver)
* Pin headers to solder to the LCD display pins
* 10k ohm potentiometer


### Schematic
* This is the schematic for this project:

<img class="img-fluid" src="{{'assets/posts/2019-10-01-arduino-lcd/lcd-schematic.png' | relative_url}}"/>


#### LCD pin out

The purpose of the pins of the LCD are shown below:

<img class="img-fluid" src="{{'assets/posts/2019-10-01-arduino-lcd/lcd-pinout.png' | relative_url}}"/>

For more information see [Components 101 - 16 x 2 LCD Module ](https://components101.com/16x2-lcd-pinout-datasheet)

#### How the circuit is connected

* The LCD has 16 pins and the first one from left to right is the Ground pin `GND` or `VSS`.
* The second pin is the `VCC/VDD` which we connect the 5 volts pin on the Arduino Board.
* A potentiometer is attached to the `Vo` pin for controlling the contrast of the display.
* The `RS` pin or register select pin is used for selecting whether we will send commands or data to the LCD.
For example if the RS pin is set on low state or zero volts, then we are sending commands to the LCD like: set the cursor to a specific location, clear the display, turn off the display and so on.
* When RS pin is set on High state (or 5 volts) we are sending data or characters to the LCD.
* Next comes the R / W pin which selects the mode whether we will read or write to the LCD. Here we use write node for writing or sending commands and data to the LCD.
* There are 8 data pins. In this project we used four of the eight pins.
* Anode pin Connected to positive `5V` through a 220 Ohm resistor.
* Cathode pin Connected to `GND` (negative).
* From the [Arduino’s official website](https://www.arduino.cc/en/Reference/LiquidCrystal) you can find and see the functions of the library which enable easy use of the LCD.
We can use the Library in 4 or 8 bit mode. In this tutorial we will use it in 4 bit mode, or we will just use 4 of the 8 data pins.

### Component diagram

* The following shows a breadboard diagram which was used for this project.

<img class="img-fluid" src="{{'assets/posts/2019-10-01-arduino-lcd/lcd-component-diagram.png' | relative_url}}"/>


### Code

* The following code snippet was used:

```c

/*
LiquidCrystal Library - Hello World

Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.

This sketch prints "Hello World!" to the LCD
and shows the time.

The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)

Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/

// include the library code:
#include <LiquidCrystal.h>

// 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);
}

void loop() {
// Print a message to the LCD.
lcd.print(" Coderdojo");
// set cursor to send line
lcd.setCursor(0,1);
// Print a message to the LCD.
lcd.print(" is Awesome!");
}

```


### Further experiments

* We experimented with additional LCD library functions using a `Hello Coderdojo!` message to auto-scroll the text from right to left in a loop as shown below:

```c
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

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 Coderdojo!");
delay(1000);
}

void loop() {
// scroll 16 positions (string length) to the left
// to move it offscreen left:
for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}

// scroll 32 positions (string length + display length) to the right
// to move it offscreen right:
for (int positionCounter = 0; positionCounter < 32; positionCounter++) {
// scroll one position right:
lcd.scrollDisplayRight();
// wait a bit:
delay(150);
}

// scroll 16 positions (display length + string length) to the left
// to move it back to center:
for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}

// delay at the end of the full loop:
delay(1000);

}



```


### Resources
* The [Arduino "Hello World"](https://www.arduino.cc/en/Tutorial/HelloWorld) tutorial on LCD and Arduino provides a useful reference.

111 changes: 111 additions & 0 deletions _posts/en/resources/2019-02-12-tinkercad-resistor-led.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
iainardo marked this conversation as resolved.
Show resolved Hide resolved
layout: article
lang: en
parent: electronic-resources
breadcrumb: true
permalink: /en/resources/electronic-resources/tinkercad-resistor-led
ref: LED circuit
title: Use Tinkercad to build a LED circuit
author: Iain Campbell
description: Tinkercad tutorials, LED and resistor experiments
tags: electronics, LED, resistor, components,circuits, tinkercad
---

## LED and resistors

### Objectives
* Take a series of Tinkercad online tutorials to get started
* Understand how to read a basic circuit diagram
* Build a LED (Light Emitting Diode) and Resistor Circuit
* Conduct a series of experiments to understand some basics principles about electronics

### Prerequisites
* It is you are already familiar with some of basic electronic components
* For a recap on components see [Basic Electronic components, how and why to use](https://www.youtube.com/watch?v=6UTOTgbJ_8E)
* Recap on [Resistors](https://kids.kiddle.co/Resistor) and what they do

### Online tutorials
* Follow the [Tinkercad Starter Tutorials Online Series ](https://www.tinkercad.com/learn/circuits/learning) to get started. This tutorial series will assist you and help you to understand the following:
* How to use Tinkercad to start simulate circuits
* How to edit, wire and add components to circuits
* Follow the [Tinkercad Further Lessons Online Tutorial Series](https://www.tinkercad.com/learn/circuits/lessons) to learn:
* How to use breadboards
* Ohm's law
* The difference between series and parallel circuits

### Reading basic circuit diagrams / schematics

* Follow the [How to Read a Schematic](https://www.youtube.com/watch?v=_HZ-EQ8Hc8E ) for a good overview about how to read basic electronic circuits
* Read [Sparkfun - How to Read a Schematic](https://learn.sparkfun.com/tutorials/how-to-read-a-schematic/all) and keep it handy as a reference.

### Build your first circuit in Tinkercad

Build a simple LED resistor circuit diagram in Tinkercad.

#### Simple LED resistor circuit diagram

<img class="img-fluid" src="{{'assets/posts/2019-02-12-tinkercad-resistor-led/battery-led-resistor.png' | relative_url}}"/>

##### Components
* 9V battery
* Jumper wires
* LED (any colour you prefer!) (x1)
* Diode
* Switch
* Resistor (220 Ω)
* Potentiometer (1kΩ )


##### Breadboard layout

<img class="img-fluid" src="{{'assets/posts/2019-02-12-tinkercad-resistor-led/resistorLED.png' | relative_url}}"/>

The following shows a basic LED resistor circuit (without the switch, diode or potentiometer - you can add these yourself as an experiment!)



### Experiments

The following experiments will help understand the basics ideas:

1. Build the Battery LED circuit shown above. However, use a 9V DC supply rather than 3V.
2. Measure the voltage across the LED when the LED is turned on. Measure the voltage across the resistor. What is the sum of the voltage ?
3. Reverse LED pins around. What happens ?
4. Take out the resistor and put 9V across the LED ? What happens ? Why ?
5. Choose different colour for LED
6. Switch LED and resistor around. What happens ? Why ? Are the resistor and LED in series or parallel ?
7. Add a [diode](https://kids.kiddle.co/Diode) in series to LED1
8. Reduce voltage from 9V to 3V. What effect does this have to the circuit ?
9. Revert to back use 9V battery again
10. Add a [potentiometer](https://www.youtube.com/watch?v=7xiHtAwyFgc) to the circuit in replacement of the resistor. Vary the resistance of the potentiometer when the circuit is active and note how this effects the LED.
11. Measure resistance across the potentiometer as you vary the resistance.
12. Add a switch to the circuit (single pole single throw SPST)
12. Measure current through circuit. In addition use Ohm's law to calculate the current, when a 9V batter is used and a 270 Ohm resistor is used.
13. Add more LEDS in parallel to existing circuit (different colours)
14. Learn more about resistors and [resistor colour codes](http://www.resistor-calculator.com/)
15. Use mnemonics to remember the resistor colour codes [“**B**ad **B**ooze **R**ots **O**ur **Y**oung **G**uts **B**ut **V**odka **G**oes **W**ell”](https://en.wikipedia.org/wiki/List_of_electronic_color_code_mnemonics) is my favorite mnemonic to remember the resistor colour code list!
16. Reverse the direction of the diode

### Quiz

* Describe to a friend how you use breadboard to prototype a circuit and how the pins of the breadboard are interconnected.
* Some components have a _____ - a positive and a negative end.
* What is the symbol for the following component

<img class="img-fluid" src="{{'assets/posts/2019-02-12-tinkercad-resistor-led/cap.png' | relative_url}}"/>

* Name some components with a positive / negative terminal.
* Battery has a voltage measured in ______ ?
* Current flows through a electronic circuit. Current in measured in ___ ?
* Resistors have a _______ code which tell you ________ ?
* If too much current flows through an LED what happens ?
* If a resistor has colour codes Red Black Orange Gold. What is it's resistance ?
* Use Ohm's law to calculate resistance. Imagine we want 20 mA of current flowing through the LED in the following circuit. What resistance value do we need for the resistor ?

<img class="img-fluid" src="{{'assets/posts/2019-02-12-tinkercad-resistor-led/quiz_findResistance.png' | relative_url}}"/>


### Report

* Write about what you learned, you can also write about your own experiments you conducted and what you discovered.
* A mentor can help publish your experiments to the [Coder Dojo Athlone Projects](https://coderdojoathlone.com/en/projects/) website!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.