• No results found

Using Push Button Switch With 8051 and Keil C

N/A
N/A
Protected

Academic year: 2021

Share "Using Push Button Switch With 8051 and Keil C"

Copied!
37
0
0

Loading.... (view fulltext now)

Full text

(1)

Using Push Button Switch with 8051 and Keil

C – AT89C51

by Ebin George / 4 Comments

This tutorial is for beginners in the field of microcontroller. In this case the microcontroller is AT89C51, a reprogrammable derivative of 8051. This purpose of this tutorial is

to familiarize with the use of push button switch with the micro controller. It will be useful whenever a decision is to be made according to the press of a switch. If you are not yet started with 8051 with Keil C please refer this tutorial Blinking Led using 8051 and Keil C.

(2)

Using Push Button Switch with 8051 Microcontroller and KeilC

Note : VCC and GND of AT89C51 is not shown in the above circuit diagram. VCC should be connected to +5 and GND should be connected to Ground of the power supply.

Push button switch is connected to the first bit of PORT 0 (P0.0) which is configured as an input pin. Which is connected to a pull up resistor such that this pin is at Vcc potential when the switch is not pressed. When the switch is pressed this pin P0.0 will be grounded. The LED is connected to the first bit of PORT 2 (P2.2) and a resistor is connected in series with it to limit the current

(3)

KEIL C Program

#include<reg52.h> /* special function register declarations */ /* for the intended 8051 derivative */ #include<stdio.h> /* prototype declarations for I/O functions */ sbit LED_pin = P2^0; //Defining LED PIN

sbit switch_pin = P0^0; //Defining Switch PIN void Delay(int); //Function prototype declaration void main (void)

{

switch_pin = 1; // Making Switch PIN input LED_pin = 0; //Making LED pin output while(1) //infinite loop

{

if(switch_pin == 0) //If switch pressed {

LED_pin = 1; //LED ON Delay(1000); //Delay LED_pin = 0; //LED OFF } } } void Delay(int k) { int j; int i; for(i=0;i<k;i++) { for(j=0;j<100;j++) { } } } Th

(4)

In some electronic applications we need to switch or control high voltages or high currents. In these cases we may use electromagnetic or solid state relays. For example, it can be used to control home appliances using low power electronic circuits.

relay

An electromagnetic relay is a switch which is used to switch High Voltage or Current using Low power circuits. It magnetically isolates low power circuits from high power circuits. It is

activated by energizing a electromagnet, coil wounded on a soft iron core. For detailed working of relay please visit this page. A relay should not be directly connected to a microcontroller, it needs a driving circuit due to the following reasons.

 A microcontroller will not able to supply current required for the proper working of a relay. The maximum current that A89C51 microcontroller can source or sink is 15mA while a relay needs about 50 – 100mA current.

 A relay is activated by energizing its coil. Microcontroller may stop working by the negative voltages produced in the relay due to its back emf.

Interfacing Relay with 8051 using Transistor

Transistor is wired as a switch. which drives the relay. When the first pin of port P2 goes high the base current flows through the 10k resistor. This in turn switches the transistor ON. The relay gets enough current through the 12v supply to switch the secondary circuit ON.

(5)

Interfacing Relay with 8051 using Transistors – Circuit Diagram

Keil C Program

#include<stdio.h> sbit relay_pin = P2^0; void Delay_ms(int); void main() { do { relay_pin = 1; //Relay ON Delay_ms(1000);

relay_pin = 0; //Relay OFF Delay_ms(1000);

}while(1); }

(6)

void Delay_ms(int k) { int j; int i; for(i=0;i<k;i++) { for(j=0;j<100;j++) { } } }

Interfacing Relay with 8051 using ULN2003

When we need more than one relays, using transistors and diodes become bulky. In these cases we can use ULN drivers. These are monolithic IC s consists of High Voltage High Current Darlington transistor arrays. When using these driver ICs we don’t need to connect freewheeling diode as they have built in clamp diodes. Here we are using ULN2003 for demostration.

(7)
(8)

Interfacing Relay with 8051 using ULN2003

Keil C Program

#include<stdio.h> #define relayport P2 void Delay_ms(int); void main() { do {

relayport = 0xFF; //All relays On Delay_ms(1000);

relayport = 0x00; //All relays Off Delay_ms(1000); }while(1); } void Delay_ms(int k) { int j; int i; for(i=0;i<k;i++) { for(j=0;j<100;j++) { } } }

(9)

Interfacing DC Motor with 8051 using L293D

– AT89C51

by Ebin George / 10 Comments

In some of the electronics projects you may want to control a DC Motor with 8051 microcontroller. The maximum current that can be sourced or sunk from a 8051

microcontroller is 15 mA at 5v. But a DC Motor need currents very much more than that and it need voltages 6v, 12v, 24v etc, depending upon the type of motor used. Another problem is that the back emf produced by the motor may affect the proper functioning of the microcontroller. Due to these reasons we can’t connect a DC Motor directly to a microcontroller.

DC Motor

To overcome these problems you may use a H-Bridge using transistors. Freewheeling diodes or Clamp diodes should be used to avoid problems due to back emf. Thus it requires transistors, diodes and resistors, which may make our circuit bulky and difficult to assembly.

To overcome this problem the L293D driver IC is used. It is a Quadruple Half H-Bridge driver and it solves the problem completely. You needn’t connect any transistors, resistors or diodes. We can easily control the switching of L293D using a microcontroller. There are two IC’s in this category L293D and L293. L239D can provide a maximum current of 600mA from 4.5V

to 36V while L293 can provide up to 1A under the same input conditions. All inputs of these ICs are TTL compatible and clamp diodes is provided with all outputs. They are used with inductive loads such as relays solenoids, motors etc.

L293D contains four Half H Bridge drivers and are enabled in pairs. EN1 is used to enable pair 1 (IN1-OUT1, IN2-OUT2) and EN2 is used to enable pair 2 (IN3-OUT3, IN4-OUT4). We can drive two DC Motors using one L293D, but here we are using only one. You can connect second DC Motor to driver pair 2 according to your needs.

(10)

Circuit Diagram

Interfacing DC Motor with 8051 using L293D

The DC Motor is connected to the first pair of drivers and it is enabled by connecting EN1 to logic HIGH (5V). VSS pin is used to provide logic voltage to L293D. Here 8051

microcontroller, which works at 5v is used to control L293D, hence the logic voltage is 5. The motor supply is given to Vs pin of the L293D.

(11)

#include<reg52.h> #include<stdio.h> void delay(void); sbit motor_pin_1 = P2^0; sbit motor_pin_2 = P2^1; void main() { do { motor_pin_1 = 1;

motor_pin_2 = 0; //Rotates Motor Anit Clockwise delay();

motor_pin_1 = 1;

motor_pin_2 = 1; //Stops Motor delay();

motor_pin_1 = 0;

motor_pin_2 = 1; //Rotates Motor Clockwise delay();

motor_pin_1 = 0;

motor_pin_2 = 0; //Stops Motor delay(); }while(1); } void delay() { int i,j; for(i=0;i<1000;i++) { for(j=0;j<1000;j++) { } } }

Control Signals and Motor Status

P2.0/IN1 P2.1/IN2 Motor Status

LOW LOW Stops

LOW HIGH Clockwise

HIGH LOW Anti-Clockwise

HIGH HIGH Stops

You can download Keil C files and Proteus files here… v

(12)

 Shop By Category

FOLLOW US ON: WE'RE SOCIAL Search

All

Interfacing Stepper Motor with 8051 using Keil C – AT89C51 by Ebin George / 8 Comments

Stepper Motor

A Stepper Motor is a brushless, synchronous DC Motor. It has many applications in the field of robotics and mechatronics. The total rotation of the motor is divided into steps. The angle of a single step is known as the stepper angle of the motor. There are two types of stepper motors

Unipolar and Bipolar. Due to the ease of operation unipolar stepper motor is commonly used by

electronics hobbyists. For more details please read the article Stepper Motor or Step Motor. Stepper Motors can be easily interfaced with a microcontroller using driver ICs such as L293D or ULN2003.

(13)

Unipolar Stepper Motor Windings

Unipolar stepper motors can be used in three modes namely the Wave Drive, Full Drive and

Half Drive mode. Each drive have its own advantages and disadvantages, thus we should choose

the required drive according to the application and power consumption.

Wave Drive

In this mode only one electromagnet is energized at a time. Generated torque will be less when compared to full drive in which two electromagnets are energized at a time but power

consumption is reduced. It has same number of steps as in the full drive. This drive is preferred when power consumption is more important than torque. It is rarely used.

Wave Drive Stepping Sequence

Step A B C D 1 1 0 0 0 2 0 1 0 0 3 0 0 1 0 4 0 0 0 1 Full Drive

In this mode two electromagnets are energized at a time, so the torque generated will be larger when compared to Wave Drive. This drive is commonly used than others. Power consumption will be higher than other modes.

(14)

Full Drive Stepping Sequence Step A B C D 1 1 1 0 0 2 0 1 1 0 3 0 0 1 1 4 1 0 0 1 Half Drive

In this mode alternatively one and two electromagnets are energized, so it is a combination of Wave and Full drives. This mode is commonly used to increase the angular resolution of the motor but the torque will be less, about 70% at its half step position. We can see that the angular resolution doubles when using Half Drive.

Half Drive Stepping Sequence

Step A B C D 1 1 0 0 0 2 1 1 0 0 3 0 1 0 0 4 0 1 1 0 5 0 0 1 0 6 0 0 1 1 7 0 0 0 1 8 1 0 0 1

(15)

Interfacing Using L293D

Interfacing Unipolar Stepper Motor with 8051 using L293D

This is the circuit diagram of driving a bipolar stepper motor using 8051 microcontroller using L293D. 24MHz crystal is connected to provide the required clock for the microcontroller. 10μF capacitor and 10KΩ is used to provide Power On Reset (POR) for the 8051 microcontroller. L293D is connected to pins P2.0, P2.1, P2.2, P2.3 of the microcontroller and two pairs of L293D are enabled by tieing EN1, EN2 to 5V. Logic Voltage (5V) is connected to Vss pin and Motor Supply (12V) is connected to the Vs pin of L293D. Center Tap of each windings of stepper motor is shorted and connected to the motor supply. Now we can energize each winding of the motor by making corresponding pin of L293D LOW.

(16)

Interfacing Using ULN2003

Interfacing Unipolar Stepper Motor with 8051 using ULN2003

In this circuit instead of L293D, ULN2003 is used. Working is similar to the previous circuit, when an input (say 1B) is HIGH corresponding output pin (1C) will be grounded. Thus we can energize any winding of stepper motor.

Keil C Code For Wave Drive

(17)

#include<stdio.h> void delay(int); void main() { do { P2=0x01; //0001 delay(1000); P2=0x02; //0010 delay(1000); P2=0x04; //0100 delay(1000); P2=0x08; //1000 delay(1000); } while(1); } void delay(int k) { int i,j; for(i=0;i<k;i++) { for(j=0;j<100;j++) {} } }

Keil C Code for Full Drive

#include<reg52.h> #include<stdio.h> void delay(int); void main() { do { P2 = 0x03; //0011 delay(1000); P2 = 0x06; //0110 delay(1000); P2 = 0x0C; //1100 delay(1000); P2 = 0x09; //1001 delay(1000); } while(1); } void delay(int k) { int i,j; for(i=0;i<k;i++)

(18)

{

for(j=0;j<100;j++) {}

} }

Keil C Code for Half Drive

#include<reg52.h> #include<stdio.h> void delay(int); void main() { do { P2=0x01; //0001 delay(1000); P2=0x03; //0011 delay(1000); P2=0x02; //0010 delay(1000); P2=0x06; //0110 delay(1000); P2=0x04; //0100 delay(1000); P2=0x0C; //1100 delay(1000); P2=0x08; //1000 delay(1000); P2=0x09; //1001 delay(1000); } while(1); } void delay(int k) { int i,j; for(i=0;i<k;i++) { for(j=0;j<100;j++) {} } }

You can simplify these codes using the shift (<< >>) operators in C.

Interfacing Bipolar Stepper Motor

Bipolar stepper motors have no center tap and having equal coil resistances. It can be easily interfaced with a microcontroller using L293D DC Motor Driver IC.

(19)

Interfacing Bipolar Stepper Motor with 8051 using L293D Keil C Code #include<reg52.h> #include<stdio.h> void delay(int); void main() { do { P2=0x01; //0001

(20)

delay(1000); P2=0x04; //0100 delay(1000); P2=0x02; //0010 delay(1000); P2=0x08; //1000 delay(1000); }while(1); } void delay(int k) { int i,j; for(i=0;i<k;i++) { for(j=0;j<100;j++) {} } }

You can download Keil C files and Proteus files here

(21)

FOLLOW US ON: WE'RE SOCIAL Search

All

Interfacing Servo Motor with 8051 using Keil C by Ebin George / 10 Comments

A servo motor uses servo mechanism, which is a closed loop mechanism that uses position feedback to control the precise angular position of the shaft. Stepper Motors, which is an open loop system can also be used for precise angular control. But Servo Motors are preferred in angular motion applications such as robotic arm. Moreover controlling of servo motors are very simple, easy and needs no extra hardware like stepper motor. Usually hobby circuit servo motors have three wires. Two of them are red and black which is used to give power to the motor and the third wire is used to provide control signal for angular position. It uses Pulse Width Modulated (PWM) waves as control signals. The angle of rotation is determined by the width of the pulse at the control pin. The servo motor used here is having angle of rotation from 0 to 180 degrees. We can control the exact angular position by varying the pulse between 1ms to 2ms. Before using this in your application, please refer the datasheet of your servo for angle and pulse width informations.

(22)

Controlling Angular Position of Servo Motor using Pulse Width Modulation

(23)
(24)

Interfacing Servo Motor with 8051 – Circuit Diagram

8MHz crystal is used to provide the required clock for 8051 microcontroller and 22pF capacitors are used to stabilize the operation of crystal. 10KΩ resistor and 10μF capacitor is used to provide the required Power On Reset (POR) to the microcontroller. Control of Servo Motor is connected to first pin of Port 2.

Keil C Code

#include<reg52.h> #include<stdio.h> #include <intrins.h> sbit motor_pin = P2^0; void Delay(unsigned int);

void Delay_servo(unsigned int); void main() { motor_pin = 0; do { //Turn to 0 degree motor_pin = 1; Delay_servo(50); motor_pin = 0; Delay(1000); //Turn to 90 degree motor_pin=1; Delay_servo(82); motor_pin=0; Delay(1000); //Turn to 180 degree motor_pin=1; Delay_servo(110); motor_pin=0; Delay(1000); }while(1); }

void Delay(unsigned int ms) {

unsigned long int us = ms*1000; while(us--)

{

_nop_(); }

}

(25)

{ while(us--) { _nop_(); } }

You can download Keil C files and Proteus files here

nterfacing Keypad with 8051 Microcontroller using Keil C by Ebin George / 12 Comments

Matrix Keypad

Matrix Keypads are commonly used in calculators, telephones etc where a number of input switches are required. We know that matrix keypad is made by arranging push button switches in row and columns. In the straight forward way to connect a 4×4 keypad (16 switches) to a

microcontroller we need 16 inputs pins. But by connecting switches in the following way we can read the status of each switch using 8 pins of the microcontroller.

(26)

The status of each keys can be determined by a process called Scanning. For the sake of explanation lets assume that all the column pins (Col1 – Col4) are connected to the inputs pins and all the row pins are connected to the output pins of the microcontroller. In the normal case all the column pins are pulled up (HIGH state) by internal or external pull up resistors. Now we can read the status of each switch through scanning.

1. A logic LOW is given to Row1 and others (Row2 – Row-4) HIGH

2. Now each Column is scanned. If any switch belongs to 1st row is pressed corresponding column will pulled down (logic LOW) and we can detect the pressed key.

3. This process is repeated for all rows.

If you need to save more pins of your microcontroller then you can interface keypad using the ADC module of your microcontroller.

(27)

Circuit diagram

(28)

10KΩ resistor and 10μF will provide the required Power On Reset (POR) signal to the 8051 microcontroller. 12MHz crystal is used to provide required clock for the microcontroller and 22pF capacitors will stabilize the oscillations of the crystal. AT89C51 can works upto 24MHz. We can choose the required frequency by changing the crystal and clock frequency in the project settings of Keil C. Keypad is connected to the Port P1 and column inputs pins are pulled up internally. 16×2 LCD is connected to Port P2 and P0. P0.0 and P0.1 pins are pulled up externally using 10KΩ resistors since Port P0 has no internal pull up.

Keil C Code

#include<reg52.h> //including sfr registers for ports of the controller #include<lcd.h> //LCD Module Connections sbit RS = P0^0; sbit EN = P0^1; sbit D0 = P2^0; sbit D1 = P2^1; sbit D2 = P2^2; sbit D3 = P2^3; sbit D4 = P2^4; sbit D5 = P2^5; sbit D6 = P2^6; sbit D7 = P2^7;

//End LCD Module Connections //Keypad Connections sbit R1 = P1^0; sbit R2 = P1^1; sbit R3 = P1^2; sbit R4 = P1^3; sbit C1 = P1^4; sbit C2 = P1^5; sbit C3 = P1^6; sbit C4 = P1^7;

//End Keypad Connections void Delay(int a) { int j; int i; for(i=0;i<a;i++) { for(j=0;j<100;j++) { } } } char Read_Keypad() { C1=1;

(29)

C2=1; C3=1; C4=1; R1=0; R2=1; R3=1; R4=1; if(C1==0){Delay(100);while(C1==0);return '7';} if(C2==0){Delay(100);while(C2==0);return '8';} if(C3==0){Delay(100);while(C3==0);return '9';} if(C4==0){Delay(100);while(C4==0);return '/';} R1=1; R2=0; R3=1; R4=1; if(C1==0){Delay(100);while(C1==0);return '4';} if(C2==0){Delay(100);while(C2==0);return '5';} if(C3==0){Delay(100);while(C3==0);return '6';} if(C4==0){Delay(100);while(C4==0);return 'X';} R1=1; R2=1; R3=0; R4=1; if(C1==0){Delay(100);while(C1==0);return '1';} if(C2==0){Delay(100);while(C2==0);return '2';} if(C3==0){Delay(100);while(C3==0);return '3';} if(C4==0){Delay(100);while(C4==0);return '-';} R1=1; R2=1; R3=1; R4=0; if(C1==0){Delay(100);while(C1==0);return 'C';} if(C2==0){Delay(100);while(C2==0);return '0';} if(C3==0){Delay(100);while(C3==0);return '=';} if(C4==0){Delay(100);while(C4==0);return '+';} return 0; } void main() { int i=0; char c,p; Lcd8_Init(); while(1) { Lcd8_Set_Cursor(1,1); Lcd8_Write_String("Keys Pressed:"); Lcd8_Set_Cursor(2,1); Lcd8_Write_String("Times:"); while(!(c = Read_Keypad())); p=c; while(p==c) { i++; Lcd8_Set_Cursor(1,14); Lcd8_Write_Char(c); Lcd8_Set_Cursor(2,7);

(30)

Lcd8_Write_Char(i+48); Delay(100); while(!(c = Read_Keypad())); } i=0; Lcd8_Clear(); } }

The code consists of two user defined functions. The Delay() is used to make delay in the

program execution. The Read_Keypad() reads the keypad. If any key is pressed it waits until the key is released and returns the corresponding character. If no key is being pressed it returns zero. As told before one of the pins of the row is kept at a logic 0 and the columns are checked for a logic 0. If a logic 0 is found the function returns a value according to the key pressed. This process is repeated for each row until a pressed key is found. If not found it will return zero. This example project will show the character of key pressed and the number of times that key is pressed on the LCD screen.

while(!(c = Read_Keypad())) is used in the program to read keypad. It is a locking call as it will wait until a key is pressed and released.

Note : The lcd is interfaced using the ‘lcd.h’ header file which is to be included in the project folder. For more details about LCD interfacing please read our article Interfacing LCD with 8051 Microcontroller.

You can download Keil C files and Proteus files here…

Interfacing Keypad with 8051 using Keil C

 Shop By Category

FOLLOW US ON: WE'RE SOCIAL Search

(31)

Interfacing LCD with 8051 using Keil C – AT89C51 by Ligo George / 94 Comments

Liquid Crystal Display (LCD) is very commonly used electronic display module and having a wide range of applications such as calculators, laptops, mobile phones etc. 16×2 character lcd display is very basic module which is commonly used in electronics devices and projects. It can display 2 lines of 16 characters. Each character is displayed using 5×7 or 5×10 pixel matrix.

16×2 Character LCD

Interfacing 16×2 LCD with 8051 using Keil C is bit complex because there is no powerful libraries in Keil C. To solve this problem we have developed a LCD library which includes commonly used features, you just need to include our header file and use it. You can download the header file at the bottom of this article.

LCD can be interfaced with microcontroller in 4 Bit or 8 Bit mode. These differs in how data is send to LCD. In 8 bit mode to write a character, 8 bit ASCII data is send through the data lines D0 – D7 and data strobe is given through E of the LCD. LCD commands which are also 8 bit are written to LCD in similar way.

But 4 Bit Mode uses only 4 data lines D4 – D7. In this mode 8 bit character ASCII data and command data are divided into two parts and send sequentially through data lines. The idea of 4 bit communication is used save pins of microcontroller. 4 bit communication is a bit slower than 8 bit communication but this speed difference can be neglected since LCDs are slow speed devices. Thus 4 bit mode data transfer is most commonly used.

(32)

Lcd8_Init() & Lcd4_Init() : These function will initialize the LCD module which is connnected

to pins defined by following bit addressable variables.

For 8 Bit Mode:

//LCD Module Connections sbit RS = P0^0; sbit EN = P0^1; sbit D0 = P2^0; sbit D1 = P2^1; sbit D2 = P2^2; sbit D3 = P2^3; sbit D4 = P2^4; sbit D5 = P2^5; sbit D6 = P2^6; sbit D7 = P2^7;

//End LCD Module Connections

For 4 Bit Mode :

//LCD Module Connections sbit RS = P0^0; sbit EN = P0^1; sbit D4 = P2^4; sbit D5 = P2^5; sbit D6 = P2^6; sbit D7 = P2^7;

//End LCD Module Connections

These connections must be defined for the proper working of the LCD library.

Lcd8_Clear() & Lcd4_Clear() : These functions will clear the LCD screen when interfaced

with 8051 in 8 bit and 4 bit mode respectively.

Lcd8_Set_Cursor() & Lcd4_Set_Cursor() : These functions are used to set the cursor position

on the lcd screen. By using this function we can change the position of character and string displayed by the following functions.

Lcd8_Write_Char() & Lcd4_Write_Char() : These functions are used to write a character to

the LCD screen.

Lcd8_Write_String() & Lcd8_Write_String() : These functions are used to write a string or

text to the LCD screen.

Lcd8_Shift_Left() & Lcd4_Shift_Left() : These functions are used to shift display left without

changing the data in display RAM.

Lcd8_Shift_Right() & Lcd8_Shift_Right() : These functions are used to shift display right

(33)

8 Bit Mode LCD Interfacing Circuit Diagram

LCD Interfacing with 8051 using Keil C – 8 Bit Mode Circuit Diagram

Keil C Code

#include<reg52.h> //including sfr registers for ports of the controller #include<lcd.h> // Can be download from bottom of this article

(34)

//LCD Module Connections sbit RS = P0^0; sbit EN = P0^1; sbit D0 = P2^0; sbit D1 = P2^1; sbit D2 = P2^2; sbit D3 = P2^3; sbit D4 = P2^4; sbit D5 = P2^5; sbit D6 = P2^6; sbit D7 = P2^7;

//End LCD Module Connections void Delay(int a) { int j; int i; for(i=0;i<a;i++) { for(j=0;j<100;j++) { } } } void main() { int i; Lcd8_Init(); while(1) { Lcd8_Set_Cursor(1,1);

Lcd8_Write_String("electroSome LCD Hello World"); for(i=0;i<15;i++) { Delay(1000); Lcd8_Shift_Left(); } for(i=0;i<15;i++) { Delay(1000); Lcd8_Shift_Right(); } Lcd8_Clear(); Lcd8_Write_Char('e'); Lcd8_Write_Char('S'); Delay(3000); } }

(35)

Circuit Diagram

(36)

Keil C Code

#include<reg52.h> //including sfr registers for ports of the controller #include<lcd.h> //Can be download from bottom of this article

//LCD Module Connections sbit RS = P0^0; sbit EN = P0^1; sbit D4 = P2^4; sbit D5 = P2^5; sbit D6 = P2^6; sbit D7 = P2^7;

//End LCD Module Connections void Delay(int a) { int j; int i; for(i=0;i<a;i++) { for(j=0;j<100;j++) { } } } void main() { int i; Lcd4_Init(); while(1) { Lcd4_Set_Cursor(1,1);

Lcd4_Write_String("electroSome LCD Hello World"); for(i=0;i<15;i++) { Delay(1000); Lcd4_Shift_Left(); } for(i=0;i<15;i++) { Delay(1000); Lcd4_Shift_Right(); } Lcd4_Clear(); Lcd4_Set_Cursor(2,1); Lcd4_Write_Char('e'); Lcd4_Write_Char('S'); Delay(2000); } }

How to use the Header File ?

Copy and Paste the header file lcd.h to your project folder. Then add lcd.h to your source group. 1. Right Click on Source Group

(37)

2. Click on “Add Files to ‘Group Source Group 1′ 3. Select lcd.h and Click Add

Optimize Code for more Efficiency

You already seen that by using our header file lcd.h you can connect LCD to any of the output pins of the microcontroller. For this more coding is required in the header file which makes the generated hex file less efficient and large in size. You can solve this problem by making some changes in the header file according to your hardware connections. For eg : in the above sample programs I have used port P2 for sending data and command. Just replace the functions

Lcd4_Port(data) and Lcd8_Port(data) with P2 = data.

References

Related documents

• E drejta e sigurimeve shoqerore eshte e lidhur ngushtesisht me te drejten e punes, per arsye se objekti i te drejtes se sigurimeve shoqerore eshte pjese e objektit qe mbulohet

When the noninverting input (Pin 3) receives a voltage less than the internal reference value, the comparator allows the triggering logic to deliver pulses to the triac gate..

We collected quantitative dietary intake data among IYC in rural Northern Ghana and used it to: (a) identify grain legumes consumption and contribution to nutri- ents in the

Pauline Howie, Chief Executive, Scottish Ambulance Service, said: “Our air ambulance se rvice is absolutely vital to the people of Scotland and the new contract will ensure that

Changes in Swedish Women’s Individual Activity Status and the Subsequent Risk of Giving Birth in the 1980s and 1990s: An Extension of Studies by Gunnar Andersson and Britta

Membranes form small assemblies between the cell wall and cytoplasmic membrane, or, as evidenced by FRAP experiments, large protein-impermeable cross-membrane structures,

While conducting research for this review, school principals and teachers in almost all of the junior secondary and senior secondary schools visited reported that while

■ Compare key theories and theorists in the study of religion ■ Interpret key thinkers and figures within religious traditions BACHELOR OF ARTS IN RELIGIOUS STUDIES (120 UNITS)..