SlideShare a Scribd company logo
1 of 3
EMBEDDED SYSTEMS TUTORIAL 9- INTERFACING 16X2
LCD WITH AVR PART-2
Hi…. friends this time I am here with another article ,we are going to discuss some interesting functions
and projects of LCD. In this tutorial we will learn about rotating a text , displaying integer and integers
operations, displaying floating point numbers and their operations .
ROTATING A TEXT STRING
Rotating a text on LCD is a bit tricky thing, to do so we will change the position of text every time with
some delay after clearing the screen so it will look like text is moving the sample code is given below just
use this source code in your LCD project and text will look like moving/*
* MOVINGTEXT.c
*
* Created: 1/12/2013 8:36:31 PM
* Author: ABHILASH DIXIT
*/

#include
#include
#include
#include
#include
#include

<stdlib.h>
<avr/io.h>
<avr/pgmspace.h>
<util/delay.h>
"lcd.h"
"lcd.c"

int main(void)
{
while(1)
{
lcd_init(LCD_DISP_ON);
for(int i=-10;i<16;i++)
// setting an integer i to 0 and incrementing
its value till 16
{
lcd_gotoxy(i,0);
// setting cursor to (i,0)
lcd_puts("LCD"); // to display text
if(i==13)
i=0;
_delay_ms(100);
// some delay
lcd_clrscr();
// clear display
}
}
}

So this was the trick to rotate the text string on the LCD.
USING INTEGERS ON LCD
You cannot use a integer on LCD directly for this you have to use a function itoa(), it converts an integer
in string form. So if we want to use integers in LCD we will first create a buffer of some size as
char buf[8];
now lets suppose the number to be displayed is i , so we will use itoa() function for i to convert it in string
form as
itoa(i,buf,10);
here 10 is for decimal, for hexadecimal we will use 16 and for binary we will use 2.
Now finally i can be displayed using lcd_puts() command aslcd_puts(buf);

so lets try a source code – in this program we will display a number i=0 and will increase its value till 10.
/*
* DISPLAY INTEGER.c
*
* Created: 1/12/2013 9:16:31 PM
* Author: ABHILASH DIXIT
*/
#include <stdlib.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "lcd.h"
#include "lcd.c"
#include <util/delay.h>
int main()
{
while(1)
{
lcd_init(LCD_DISP_ON);
int i=0;
char buf[8];
lcd_gotoxy(0,0);
lcd_puts("i=");
for(i=0;i<=9;i++)
{
itoa(i,buf,10);
lcd_gotoxy(2,0);
lcd_puts(buf);
_delay_ms(100);
}
}
}

USING A FLOATING POINT NUMBER

// initializing display
// setting value of integer i to 0
// initializing buffer
// setting cursor position to (0,0)
// displaying text
// increasing value of i till 9
// using itoa() function
// setting cursor position to (2,0)
// displaying value of i every time
// some delay
Like an integer a floating point number cannot be used directly too , so to use an floating point no on LCD
we have to use some function called dtostrf() it converts an floating point number into string . let us
suppose we have to display a floating point number say i on LCD. So first of all we have to create a
buffer of some size
char buf[8];
then we will use dtostrf () function with i to convert i in string form as
dtostrf(i,10,6,buf);
here 10 is for decimal and 6 is denoting numbers after decimal we can change it accordingly.
Now the no i can be displayed using lcd_puts() command
Here is the source code for simply displaying a floating point number i=1.12345

/*
* DISPLAY FLOAT.c
*
* Created: 1/12/2013 9:26:31 PM
* Author: ABHILASH DIXIT
*/
#include <stdlib.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "lcd.h"
#include "lcd.c"
int main()
{
lcd_init(LCD_DISP_ON);
float i=1.12345;
char buf[8];
dtostrf(i,10,6,buf);
lcd_puts(buf);
}

NOTE:- to use itoa() and dtostrf() we must include stdlib.h header file in beginning of the program .

I hope it was a useful article for you all……in case of any query, doubt or critical view just leave a
comment……..in next tutorial we well discuss about some other embedded systems topics till then
………..bye..

More Related Content

What's hot

讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法pycontw
 
Android Developer Days: Increasing performance of big arrays processing on An...
Android Developer Days: Increasing performance of big arrays processing on An...Android Developer Days: Increasing performance of big arrays processing on An...
Android Developer Days: Increasing performance of big arrays processing on An...Stanfy
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervosoLuis Vendrame
 
completion_proc and history
completion_proc and historycompletion_proc and history
completion_proc and historyNobuhiro IMAI
 
ClojureScript - A functional Lisp for the browser
ClojureScript - A functional Lisp for the browserClojureScript - A functional Lisp for the browser
ClojureScript - A functional Lisp for the browserFalko Riemenschneider
 
Probability of finding a single qubit in a state
Probability of finding a single qubit in a stateProbability of finding a single qubit in a state
Probability of finding a single qubit in a stateVijayananda Mohire
 
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)Igalia
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"OdessaJS Conf
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"OdessaJS Conf
 
Open GL Programming Training Session I
Open GL Programming Training Session IOpen GL Programming Training Session I
Open GL Programming Training Session INEEVEE Technologies
 
LLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, JapanLLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, Japanujihisa
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计Alipay
 

What's hot (20)

Open gl polygon code review
Open gl polygon code reviewOpen gl polygon code review
Open gl polygon code review
 
讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Android Developer Days: Increasing performance of big arrays processing on An...
Android Developer Days: Increasing performance of big arrays processing on An...Android Developer Days: Increasing performance of big arrays processing on An...
Android Developer Days: Increasing performance of big arrays processing on An...
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
completion_proc and history
completion_proc and historycompletion_proc and history
completion_proc and history
 
ClojureScript - A functional Lisp for the browser
ClojureScript - A functional Lisp for the browserClojureScript - A functional Lisp for the browser
ClojureScript - A functional Lisp for the browser
 
Probability of finding a single qubit in a state
Probability of finding a single qubit in a stateProbability of finding a single qubit in a state
Probability of finding a single qubit in a state
 
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
 
Codejunk Ignitesd
Codejunk IgnitesdCodejunk Ignitesd
Codejunk Ignitesd
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
 
Wcbpijwbpij new
Wcbpijwbpij newWcbpijwbpij new
Wcbpijwbpij new
 
ADS-B Out Experiment
ADS-B Out ExperimentADS-B Out Experiment
ADS-B Out Experiment
 
Open GL Programming Training Session I
Open GL Programming Training Session IOpen GL Programming Training Session I
Open GL Programming Training Session I
 
LLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, JapanLLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, Japan
 
Bitcoin:Next
Bitcoin:NextBitcoin:Next
Bitcoin:Next
 
Mauro yaguachi
Mauro yaguachiMauro yaguachi
Mauro yaguachi
 
Ayam potong
Ayam potongAyam potong
Ayam potong
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计
 

Similar to Est 8 2 nd

REPORT MINI PROJECT.docx
REPORT MINI PROJECT.docxREPORT MINI PROJECT.docx
REPORT MINI PROJECT.docxZarifah5
 
C++totural file
C++totural fileC++totural file
C++totural filehalaisumit
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Windows Developer
 
Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game Pritam Samanta
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docxeugeniadean34240
 
C++ Course - Lesson 1
C++ Course - Lesson 1C++ Course - Lesson 1
C++ Course - Lesson 1Mohamed Ahmed
 
For this phase of the course project, you will research a bank to .docx
For this phase of the course project, you will research a bank to .docxFor this phase of the course project, you will research a bank to .docx
For this phase of the course project, you will research a bank to .docxhanneloremccaffery
 
Toonz code leaves much to be desired
Toonz code leaves much to be desiredToonz code leaves much to be desired
Toonz code leaves much to be desiredPVS-Studio
 

Similar to Est 8 2 nd (20)

_LCD display-mbed.pdf
_LCD display-mbed.pdf_LCD display-mbed.pdf
_LCD display-mbed.pdf
 
Est 8 1 st
Est 8 1 stEst 8 1 st
Est 8 1 st
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Lab Activity 3
Lab Activity 3Lab Activity 3
Lab Activity 3
 
C++ tutorial
C++ tutorialC++ tutorial
C++ tutorial
 
REPORT MINI PROJECT.docx
REPORT MINI PROJECT.docxREPORT MINI PROJECT.docx
REPORT MINI PROJECT.docx
 
C++totural file
C++totural fileC++totural file
C++totural file
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 
Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game
 
Quiz 9
Quiz 9Quiz 9
Quiz 9
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Howto curses
Howto cursesHowto curses
Howto curses
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
Alp lcd
Alp lcdAlp lcd
Alp lcd
 
C++ Course - Lesson 1
C++ Course - Lesson 1C++ Course - Lesson 1
C++ Course - Lesson 1
 
For this phase of the course project, you will research a bank to .docx
For this phase of the course project, you will research a bank to .docxFor this phase of the course project, you will research a bank to .docx
For this phase of the course project, you will research a bank to .docx
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
C++
C++C++
C++
 
Toonz code leaves much to be desired
Toonz code leaves much to be desiredToonz code leaves much to be desired
Toonz code leaves much to be desired
 

More from Akshay Sharma

Eye monitored wheel chair control for people suffering from quadriplegia
Eye monitored wheel chair control for people suffering from quadriplegiaEye monitored wheel chair control for people suffering from quadriplegia
Eye monitored wheel chair control for people suffering from quadriplegiaAkshay Sharma
 
The next generation classroom smart, interactive and connected learning envir...
The next generation classroom smart, interactive and connected learning envir...The next generation classroom smart, interactive and connected learning envir...
The next generation classroom smart, interactive and connected learning envir...Akshay Sharma
 
Over voltage protector circuit
Over voltage protector circuitOver voltage protector circuit
Over voltage protector circuitAkshay Sharma
 
Double Side Band – Suppressed Carrier (DSB-SC) Modulation Demodulation using ...
Double Side Band – Suppressed Carrier (DSB-SC) Modulation Demodulation using ...Double Side Band – Suppressed Carrier (DSB-SC) Modulation Demodulation using ...
Double Side Band – Suppressed Carrier (DSB-SC) Modulation Demodulation using ...Akshay Sharma
 
A_law_and_Microlaw_companding
A_law_and_Microlaw_compandingA_law_and_Microlaw_companding
A_law_and_Microlaw_compandingAkshay Sharma
 
Ldr based line follower robot
Ldr based line follower robotLdr based line follower robot
Ldr based line follower robotAkshay Sharma
 
Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full TutorialAkshay Sharma
 

More from Akshay Sharma (13)

Eye monitored wheel chair control for people suffering from quadriplegia
Eye monitored wheel chair control for people suffering from quadriplegiaEye monitored wheel chair control for people suffering from quadriplegia
Eye monitored wheel chair control for people suffering from quadriplegia
 
The buzzer glove
The buzzer gloveThe buzzer glove
The buzzer glove
 
The next generation classroom smart, interactive and connected learning envir...
The next generation classroom smart, interactive and connected learning envir...The next generation classroom smart, interactive and connected learning envir...
The next generation classroom smart, interactive and connected learning envir...
 
Over voltage protector circuit
Over voltage protector circuitOver voltage protector circuit
Over voltage protector circuit
 
Haptic technology
Haptic technologyHaptic technology
Haptic technology
 
Double Side Band – Suppressed Carrier (DSB-SC) Modulation Demodulation using ...
Double Side Band – Suppressed Carrier (DSB-SC) Modulation Demodulation using ...Double Side Band – Suppressed Carrier (DSB-SC) Modulation Demodulation using ...
Double Side Band – Suppressed Carrier (DSB-SC) Modulation Demodulation using ...
 
A_law_and_Microlaw_companding
A_law_and_Microlaw_compandingA_law_and_Microlaw_companding
A_law_and_Microlaw_companding
 
8085 instructions
8085 instructions8085 instructions
8085 instructions
 
Ldr based line follower robot
Ldr based line follower robotLdr based line follower robot
Ldr based line follower robot
 
Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full Tutorial
 
Est 11
Est 11Est 11
Est 11
 
Est 6
Est 6Est 6
Est 6
 
Est 1
Est 1Est 1
Est 1
 

Recently uploaded

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 

Recently uploaded (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

Est 8 2 nd

  • 1. EMBEDDED SYSTEMS TUTORIAL 9- INTERFACING 16X2 LCD WITH AVR PART-2 Hi…. friends this time I am here with another article ,we are going to discuss some interesting functions and projects of LCD. In this tutorial we will learn about rotating a text , displaying integer and integers operations, displaying floating point numbers and their operations . ROTATING A TEXT STRING Rotating a text on LCD is a bit tricky thing, to do so we will change the position of text every time with some delay after clearing the screen so it will look like text is moving the sample code is given below just use this source code in your LCD project and text will look like moving/* * MOVINGTEXT.c * * Created: 1/12/2013 8:36:31 PM * Author: ABHILASH DIXIT */ #include #include #include #include #include #include <stdlib.h> <avr/io.h> <avr/pgmspace.h> <util/delay.h> "lcd.h" "lcd.c" int main(void) { while(1) { lcd_init(LCD_DISP_ON); for(int i=-10;i<16;i++) // setting an integer i to 0 and incrementing its value till 16 { lcd_gotoxy(i,0); // setting cursor to (i,0) lcd_puts("LCD"); // to display text if(i==13) i=0; _delay_ms(100); // some delay lcd_clrscr(); // clear display } } } So this was the trick to rotate the text string on the LCD.
  • 2. USING INTEGERS ON LCD You cannot use a integer on LCD directly for this you have to use a function itoa(), it converts an integer in string form. So if we want to use integers in LCD we will first create a buffer of some size as char buf[8]; now lets suppose the number to be displayed is i , so we will use itoa() function for i to convert it in string form as itoa(i,buf,10); here 10 is for decimal, for hexadecimal we will use 16 and for binary we will use 2. Now finally i can be displayed using lcd_puts() command aslcd_puts(buf); so lets try a source code – in this program we will display a number i=0 and will increase its value till 10. /* * DISPLAY INTEGER.c * * Created: 1/12/2013 9:16:31 PM * Author: ABHILASH DIXIT */ #include <stdlib.h> #include <avr/io.h> #include <avr/pgmspace.h> #include "lcd.h" #include "lcd.c" #include <util/delay.h> int main() { while(1) { lcd_init(LCD_DISP_ON); int i=0; char buf[8]; lcd_gotoxy(0,0); lcd_puts("i="); for(i=0;i<=9;i++) { itoa(i,buf,10); lcd_gotoxy(2,0); lcd_puts(buf); _delay_ms(100); } } } USING A FLOATING POINT NUMBER // initializing display // setting value of integer i to 0 // initializing buffer // setting cursor position to (0,0) // displaying text // increasing value of i till 9 // using itoa() function // setting cursor position to (2,0) // displaying value of i every time // some delay
  • 3. Like an integer a floating point number cannot be used directly too , so to use an floating point no on LCD we have to use some function called dtostrf() it converts an floating point number into string . let us suppose we have to display a floating point number say i on LCD. So first of all we have to create a buffer of some size char buf[8]; then we will use dtostrf () function with i to convert i in string form as dtostrf(i,10,6,buf); here 10 is for decimal and 6 is denoting numbers after decimal we can change it accordingly. Now the no i can be displayed using lcd_puts() command Here is the source code for simply displaying a floating point number i=1.12345 /* * DISPLAY FLOAT.c * * Created: 1/12/2013 9:26:31 PM * Author: ABHILASH DIXIT */ #include <stdlib.h> #include <avr/io.h> #include <avr/pgmspace.h> #include "lcd.h" #include "lcd.c" int main() { lcd_init(LCD_DISP_ON); float i=1.12345; char buf[8]; dtostrf(i,10,6,buf); lcd_puts(buf); } NOTE:- to use itoa() and dtostrf() we must include stdlib.h header file in beginning of the program . I hope it was a useful article for you all……in case of any query, doubt or critical view just leave a comment……..in next tutorial we well discuss about some other embedded systems topics till then ………..bye..