SlideShare a Scribd company logo
// RS = P1.16 //successful programforarm7 basedfloodalertsystemdate 4/4/2013 for
GulabroCOE
// EN = P1.17
// D4 = P1.18
// D5 = P1.19
// D6 = P1.20
// D7 = P1.21
#include "LPC214x.H" // LPC2148
MPU Register
#include <stdio.h>
// Define LCDPinIOMask
#define LCD_RS 0x00010000 // P1.16(0000 0000
0000 000x 0000 0000 0000 0000)
#define LCD_EN 0x00020000 // P1.17(0000 0000
0000 00x0 0000 0000 0000 0000)
#define LCD_D4 0x00040000 // P1.18(0000 0000
0000 0x00 0000 0000 0000 0000)
#define LCD_D5 0x00080000 // P1.19(0000 0000
0000 x000 0000 0000 0000 0000)
#define LCD_D6 0x00100000 // P1.20(0000 0000
000x 0000 0000 0000 0000 0000)
#define LCD_D7 0x00200000 // P1.21(0000 0000
00x0 0000 0000 0000 0000 0000)
#define LCD_DATA (LCD_D7|LCD_D6|LCD_D5|LCD_D4)
#define LCD_IOALL (LCD_D7|LCD_D6|LCD_D5|LCD_D4|LCD_RS|LCD_EN)
#define lcd_rs_set() IOSET1= LCD_RS // RS = 1 (SelectInstruction)
#define lcd_rs_clr() IOCLR1= LCD_RS // RS = 0 (SelectData)
#define lcd_en_set() IOSET1= LCD_EN // EN = 1 (Enable)
#define lcd_en_clr() IOCLR1=LCD_EN // EN = 0 (Disable)
// xxxx xxx00000 0000 0000 0000 0000 0000
#define lcd_dir_write() IODIR1|= 0x003F0000 // LCD Data Bus = Write
//#define lcd_dir_read() IODIR1&= 0xFFC3FFFF // LCD Data Bus = Read
#define lcd_clear() lcd_write_control(0x01) // ClearDisplay
#define lcd_cursor_home() lcd_write_control(0x02) // SetCursor= 0
#define lcd_display_on() lcd_write_control(0x0E) // LCD DisplayEnable
#define lcd_display_off() lcd_write_control(0x08) // LCD DisplayDisable
#define lcd_cursor_blink() lcd_write_control(0x0F) // SetCursor= Blink
#define lcd_cursor_on() lcd_write_control(0x0E) // Enable LCD Cursor
#define lcd_cursor_off() lcd_write_control(0x0C) // Disable LCDCursor
#define lcd_cursor_left() lcd_write_control(0x10) // ShiftLeftCursor
#define lcd_cursor_right() lcd_write_control(0x14) // ShiftRightCursor
#define lcd_display_sleft() lcd_write_control(0x18) // ShiftLeftDisplay
#define lcd_display_sright() lcd_write_control(0x1C) // ShiftRightDisplay
/* pototype section */
voidlcd_init(void); //
Initial LCD
voidlcd_out_data4(unsignedchar); // Strobe 4-BitData
to LCD
voidlcd_write_byte(unsignedchar); // Write 1 Byte Data
to LCD
voidlcd_write_control(unsignedchar); // Write Instruction
voidlcd_write_ascii(unsignedchar); // Write LCD Display(ASCII)
voidgoto_cursor(unsignedchar); // SetPosition
Cursor LCD
voidlcd_print(unsignedchar*); // PrintDisplayto
LCD
//char busy_lcd(void); // Read
BusyLCD Status
voidenable_lcd(void); // Enable
Pulse
voiddelay(unsignedlongint); // DelayFunction
unsignedlongtemp1,temp2;
/* Main Program Start Here */
intmain(void)
{
lcd_init(); //
Initial LCD
PINSEL0 = PINSEL0 & 0x00000000; //16 bitlowerof port0
PINSEL1 = PINSEL1 & 0x00000000; //16 bithigherof port 0
IODIR0 = IODIR0 |0x00f0FF00; //port0 directionreg32bit
PINSEL2 = PINSEL2 & 0xFFFFFFF7;
IODIR1 = IODIR1 |0x00FF0000;
//Loop PrintMessage to LCD16 x 2 //
while(1)
// LoopContinue
{
lcd_write_control(0x01); // Clear
Display (ClearDisplay,SetDDRAMAddress=0)
goto_cursor(0x00); // Set
Cursor Line-1
lcd_print("ARM7 Based"); // DisplayLCDLine-1
goto_cursor(0x40); // Set
Cursor = Line-2
lcd_print("FloodAlert "); // DisplayLCDLine-2
delay(100000); // Display
Delay
lcd_write_control(0x01); // Clear
Display (ClearDisplay,SetDDRAMAddress=0)
goto_cursor(0x00); //
SetCursor Line-1
lcd_print(" Systemusing"); // DisplayLCDLine-1
goto_cursor(0x40); // Set
Cursor = Line-2
lcd_print("Wireless"); // DisplayLCDLine-2
delay(100000); // Display
Delay
if( IOPIN0=( IOPIN0& 0x00000004 ))
{
{
temp1 = IOPIN0;
temp2 = (temp1& 0x000f0000)>>16 ;
if(temp2==0x00000001)
{
IOSET0 = IOSET0 |0x00001100; //msg1play
delay(100000);
IOCLR0 = IOCLR0 |0x00000100;
lcd_write_control(0x01); // Clear
Display (ClearDisplay,SetDDRAMAddress=0)
goto_cursor(0x00); // Set
Cursor Line-1
lcd_print("FloodWarning"); // DisplayLCDLine-1
delay(100000); //
DisplayDelay
lcd_write_control(0x01); // Clear
Display (ClearDisplay,SetDDRAMAddress=0)
goto_cursor(0x00); // Set
Cursor Line-1
lcd_print("DAMGATE OPEN "); // DisplayLCDLine-1
delay(100000); //
DisplayDelay
}
if(temp2==0x00000002)
{
IOSET0 = IOSET0 |0x00001200; //msg2play
delay(100000);
IOCLR0 = IOCLR0 |0x00000200;
}
if(temp2==0x00000003)
{
IOSET0 = IOSET0 |0x00003400; //msg3play
delay(100000);
IOCLR0 = IOCLR0 |0x00003400;
lcd_write_control(0x01); //
ClearDisplay (ClearDisplay,SetDDRAMAddress=0)
goto_cursor(0x00); // Set
Cursor Line-1
lcd_print("NORMALCONDITION "); // DisplayLCDLine-1
delay(100000); //
DisplayDelay
lcd_write_control(0x01); // Clear
Display (ClearDisplay,SetDDRAMAddress=0)
goto_cursor(0x00); // Set
Cursor Line-1
lcd_print("DAMGATE CLOSE "); // DisplayLCDLine-1
delay(100000); //
DisplayDelay
}
}
}
}
}
/****************************/
/* Strobe 4-Bit Data to LCD */
/****************************/
voidlcd_out_data4(unsignedcharval)
{
IOCLR1 = (LCD_DATA); // Reset4-
Bit PinData
IOSET1 = (val<<18); //
EN,0,RW,RS:DDDD:0000:0000:0000:0000:0000:0000
}
/****************************/
/* Write Data 1 Byte to LCD */
/****************************/
voidlcd_write_byte(unsignedcharval)
{
lcd_out_data4((val>>4)&0x0F); // Strobe 4-BitHigh-
Nibble toLCD
enable_lcd(); //
Enable Pulse
lcd_out_data4(val&0x0F); // Strobe 4-
Bit Low-Nibble toLCD
enable_lcd(); //
Enable Pulse
delay(100000);
//while(busy_lcd()); // WaitLCD
Execute Complete
}
/****************************/
/* Write InstructiontoLCD */
/****************************/
voidlcd_write_control(unsignedcharval)
{
lcd_rs_clr(); //
RS = 0 = InstructionSelect
lcd_write_byte(val); // Strobe
CommandByte
}
/****************************/
/* Write Data(ASCII) toLCD */
/****************************/
voidlcd_write_ascii(unsignedcharc)
{
lcd_rs_set(); //
RS = 1 = Data Select
lcd_write_byte(c); // Strobe 1
Byte to LCD
}
/*******************************/
/* Initial 4-BitLCD Interface */
/*******************************/
voidlcd_init()
{
unsignedinti; // LCD
Initial DelayCount
PINSEL2 = 0x00000000; //
GPIO1[31..26] = I/OFunction
lcd_dir_write(); //
LCD Data Bus= Write
for(i=0;i<1000;i++); // Power-OnDelay
(15 mS)
IOCLR1 = (LCD_IOALL); // Reset
(RS,RW,EN,4-BitData) Pin
IOSET1 = (LCD_D5|LCD_D4); //
DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000
enable_lcd(); //
Enable Pulse
for(i=0;i<100;i++); // Delay4.1mS
IOCLR1 = (LCD_IOALL); // Reset
(RS,RW,EN,4-BitData) Pin
IOSET1 = (LCD_D5|LCD_D4); //
DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000
enable_lcd(); //
Enable Pulse
for(i=0;i<100;i++); // delay
100uS
IOCLR1 = (LCD_IOALL); // Reset
(RS,RW,EN,4-BitData) Pin
IOSET1 = (LCD_D5|LCD_D4); //
DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000
enable_lcd(); //
Enable Pulse
delay(10000);
//while(busy_lcd()); // WaitLCD
Execute Complete
IOCLR1 = (LCD_IOALL); // Reset
(RS,RW,EN,4-BitData) Pin
IOSET1 = (LCD_D5); //
DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000
enable_lcd(); //
Enable Pulse
delay(10000);
//while(busy_lcd()); // WaitLCD
Execute Complete
lcd_write_control(0x28); // FunctionSet
(DL=0 4-Bit,N=12 Line,F=05X7)
lcd_write_control(0x0C); // Displayon/off
Control (EntryDisplay,Cursoroff,CursornotBlink)
lcd_write_control(0x06); // Entry Mode Set
(I/D=1 Increment,S=0CursorShift)
lcd_write_control(0x01); // ClearDisplay
(ClearDisplay,SetDDRAMAddress=0)
for(i=0;i<100000;i++); // WaitCommand
Ready
}
/***************************/
/* Set LCD PositionCursor*/
/***************************/
voidgoto_cursor(unsignedchari)
{
i |= 0x80; //
SetDD-RAMAddressCommand
lcd_write_control(i);
}
/************************************/
/* PrintDisplayData(ASCII) toLCD*/
/************************************/
voidlcd_print(unsignedchar*str)
{
inti;
for(i=0;i<16 && str[i]!=0;i++) // 16 CharacterPrint
{
lcd_write_ascii(str[i]); // PrintByte to LCD
}
}
/******************/
/* Wait LCD Ready*/
/******************/
/*char busy_lcd(void)
{
unsignedlongbusy_status; // BusyStatusRead
unsignedinti; // Delay
Count
lcd_dir_read(); // LCD Data
Bus = Read
lcd_rs_clr(); //
InstructionSelect
lcd_rw_set(); // Read
Direction
lcd_en_set(); //
Start ReadBusy
for(i=0;i<1000;i++); // Delay
Before Read
busy_status= (IOPIN1&0x80000000); // ReadLCD
Data(DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000)
if(busy_status==0x80000000) // Read& Check
BusyFlag
{
lcd_en_clr(); // Disable
Read
lcd_rw_clr(); //
Default= Write Direction
lcd_dir_write(); // LCD Data
Bus = Write
return1; //
LCD Busy Status
}
else
{
lcd_en_clr(); // Disable
Read
lcd_rw_clr(); //
Default= Write Direction
lcd_dir_write(); // LCD Data
Bus = Write
return0; //
LCD ReadyStatus
}
}
*/
/***********************/
/* Enable Pulse toLCD */
/***********************/
voidenable_lcd(void) // Enable
Pulse
{
unsignedinti; // Delay
Count
lcd_en_set(); // Enable
ON
for(i=0;i<400000;i++);
lcd_en_clr(); // Enable
OFF
}
/***********************/
/* DelayTime Function*/
/* 1-4294967296 */
/***********************/
voiddelay(unsignedlongintcount1)
{
while(count1>0) {count1--;} // Loop Decrease
Counter
}

More Related Content

What's hot

Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
Ramesh Naik Bhukya
 
(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program
Dimz I
 
Digital system design lab manual
Digital system design lab manualDigital system design lab manual
Digital system design lab manual
Santhosh Poralu
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
hairilfaiz86
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesRicardo Castro
 
Controlling Motors for Robot
Controlling Motors for RobotControlling Motors for Robot
Controlling Motors for Robot
Varad Manglekar
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab report
Ramesh Naik Bhukya
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
Jens Siebert
 
Ir remote kit_blink.pde
Ir remote kit_blink.pdeIr remote kit_blink.pde
Ir remote kit_blink.pde
Core Pale
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015
Rodrigo Almeida
 
Embedded systems development Defcon 19
Embedded systems development Defcon 19Embedded systems development Defcon 19
Embedded systems development Defcon 19
Rodrigo Almeida
 
22 Microcontroller Programs
22 Microcontroller Programs22 Microcontroller Programs
22 Microcontroller Programs
babak danyal
 
m.tech esd lab manual for record
m.tech esd lab manual for recordm.tech esd lab manual for record
m.tech esd lab manual for record
G Lemuel George
 
Dronecode: software open source em drones
Dronecode: software open source em dronesDronecode: software open source em drones
Dronecode: software open source em drones
International Drone Day Campinas
 
VOCODER LST 36 pin signal data
VOCODER LST 36 pin signal dataVOCODER LST 36 pin signal data
VOCODER LST 72 pin signal data
VOCODER LST  72 pin signal dataVOCODER LST  72 pin signal data
Controller Implementation in Verilog
Controller Implementation in VerilogController Implementation in Verilog
Controller Implementation in Verilog
Anees Akhtar
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpga
Hossam Hassan
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINOS Ayub
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
Dobrica Pavlinušić
 

What's hot (20)

Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program
 
Digital system design lab manual
Digital system design lab manualDigital system design lab manual
Digital system design lab manual
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gates
 
Controlling Motors for Robot
Controlling Motors for RobotControlling Motors for Robot
Controlling Motors for Robot
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab report
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 
Ir remote kit_blink.pde
Ir remote kit_blink.pdeIr remote kit_blink.pde
Ir remote kit_blink.pde
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015
 
Embedded systems development Defcon 19
Embedded systems development Defcon 19Embedded systems development Defcon 19
Embedded systems development Defcon 19
 
22 Microcontroller Programs
22 Microcontroller Programs22 Microcontroller Programs
22 Microcontroller Programs
 
m.tech esd lab manual for record
m.tech esd lab manual for recordm.tech esd lab manual for record
m.tech esd lab manual for record
 
Dronecode: software open source em drones
Dronecode: software open source em dronesDronecode: software open source em drones
Dronecode: software open source em drones
 
VOCODER LST 36 pin signal data
VOCODER LST 36 pin signal dataVOCODER LST 36 pin signal data
VOCODER LST 36 pin signal data
 
VOCODER LST 72 pin signal data
VOCODER LST  72 pin signal dataVOCODER LST  72 pin signal data
VOCODER LST 72 pin signal data
 
Controller Implementation in Verilog
Controller Implementation in VerilogController Implementation in Verilog
Controller Implementation in Verilog
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpga
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
 

Viewers also liked

Gate Operation at Morris Sheppard Dam, Possum Kingdom Lake
Gate Operation at Morris Sheppard Dam, Possum Kingdom LakeGate Operation at Morris Sheppard Dam, Possum Kingdom Lake
Gate Operation at Morris Sheppard Dam, Possum Kingdom Lake
Jackie Fewell
 
Uniter asphalt paver manufacturer - company profile
Uniter   asphalt paver manufacturer - company profileUniter   asphalt paver manufacturer - company profile
Uniter asphalt paver manufacturer - company profile
uniterengineeringproducts
 
How the Gates Operate at Morris Sheppard Dam
How the Gates Operate at Morris Sheppard DamHow the Gates Operate at Morris Sheppard Dam
How the Gates Operate at Morris Sheppard DamJackie Fewell
 
Dam gate hoist, head gate hoist, electric gate gear, sluice gate lifting gear...
Dam gate hoist, head gate hoist, electric gate gear, sluice gate lifting gear...Dam gate hoist, head gate hoist, electric gate gear, sluice gate lifting gear...
Dam gate hoist, head gate hoist, electric gate gear, sluice gate lifting gear...
Jacton Electromechanical Co.,Ltd
 
Awwa c501 1980 cast iron sluice gates
Awwa c501 1980 cast iron sluice gatesAwwa c501 1980 cast iron sluice gates
Awwa c501 1980 cast iron sluice gates
Eagle3232
 
Rule level & gate operation
Rule level & gate operationRule level & gate operation
Rule level & gate operation
Tushar Dholakia
 
inspection of gates of Dam
inspection of gates of Daminspection of gates of Dam
inspection of gates of Dam
Tushar Dholakia
 
4th yer ppt
4th yer  ppt4th yer  ppt
4th yer ppt
Yogesh Thakur
 
Design of Bandhara / Weir Dam gates using plastic materials_Design Directions...
Design of Bandhara / Weir Dam gates using plastic materials_Design Directions...Design of Bandhara / Weir Dam gates using plastic materials_Design Directions...
Design of Bandhara / Weir Dam gates using plastic materials_Design Directions...
India Water Portal
 
Project rubber dam ppt
Project rubber dam pptProject rubber dam ppt
Project rubber dam ppt
Vinith Pillai
 
Design Aspects of Gates of Dam
Design Aspects of Gates of DamDesign Aspects of Gates of Dam
Design Aspects of Gates of Dam
Tushar Dholakia
 
Hydraulics
HydraulicsHydraulics
Hydraulics
Jinesh Patel
 
Hydraulic structures
Hydraulic structuresHydraulic structures
Hydraulic structures
Khushnuma Wasim
 
Design of Hydraulic Structure
Design of Hydraulic StructureDesign of Hydraulic Structure
Design of Hydraulic Structure
Vidhi Khokhani
 
Design and manufacturing of hydraulic cylinders
Design and manufacturing of hydraulic cylindersDesign and manufacturing of hydraulic cylinders
Design and manufacturing of hydraulic cylinders
• Mauricio Andres Montecinos Duran •
 

Viewers also liked (19)

Gate Operation at Morris Sheppard Dam, Possum Kingdom Lake
Gate Operation at Morris Sheppard Dam, Possum Kingdom LakeGate Operation at Morris Sheppard Dam, Possum Kingdom Lake
Gate Operation at Morris Sheppard Dam, Possum Kingdom Lake
 
Uniter asphalt paver manufacturer - company profile
Uniter   asphalt paver manufacturer - company profileUniter   asphalt paver manufacturer - company profile
Uniter asphalt paver manufacturer - company profile
 
Dwyer Sess3 101309
Dwyer Sess3 101309Dwyer Sess3 101309
Dwyer Sess3 101309
 
How the Gates Operate at Morris Sheppard Dam
How the Gates Operate at Morris Sheppard DamHow the Gates Operate at Morris Sheppard Dam
How the Gates Operate at Morris Sheppard Dam
 
Dam gate hoist, head gate hoist, electric gate gear, sluice gate lifting gear...
Dam gate hoist, head gate hoist, electric gate gear, sluice gate lifting gear...Dam gate hoist, head gate hoist, electric gate gear, sluice gate lifting gear...
Dam gate hoist, head gate hoist, electric gate gear, sluice gate lifting gear...
 
Awwa c501 1980 cast iron sluice gates
Awwa c501 1980 cast iron sluice gatesAwwa c501 1980 cast iron sluice gates
Awwa c501 1980 cast iron sluice gates
 
Rule level & gate operation
Rule level & gate operationRule level & gate operation
Rule level & gate operation
 
inspection of gates of Dam
inspection of gates of Daminspection of gates of Dam
inspection of gates of Dam
 
4th yer ppt
4th yer  ppt4th yer  ppt
4th yer ppt
 
Presentation1
Presentation1Presentation1
Presentation1
 
Design of Bandhara / Weir Dam gates using plastic materials_Design Directions...
Design of Bandhara / Weir Dam gates using plastic materials_Design Directions...Design of Bandhara / Weir Dam gates using plastic materials_Design Directions...
Design of Bandhara / Weir Dam gates using plastic materials_Design Directions...
 
dam
damdam
dam
 
Project rubber dam ppt
Project rubber dam pptProject rubber dam ppt
Project rubber dam ppt
 
Design Aspects of Gates of Dam
Design Aspects of Gates of DamDesign Aspects of Gates of Dam
Design Aspects of Gates of Dam
 
Hydraulics
HydraulicsHydraulics
Hydraulics
 
Hydraulic structures
Hydraulic structuresHydraulic structures
Hydraulic structures
 
Design of Hydraulic Structure
Design of Hydraulic StructureDesign of Hydraulic Structure
Design of Hydraulic Structure
 
Design and manufacturing of hydraulic cylinders
Design and manufacturing of hydraulic cylindersDesign and manufacturing of hydraulic cylinders
Design and manufacturing of hydraulic cylinders
 
Gravity dam
Gravity damGravity dam
Gravity dam
 

Similar to Dam gate open close lpc prog

Lcd n PIC16F
Lcd n PIC16FLcd n PIC16F
Lcd n PIC16F
hairilfaiz86
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
julioalexanderaguila
 
Atmega lcd programing_with_header_file
Atmega lcd programing_with_header_fileAtmega lcd programing_with_header_file
Atmega lcd programing_with_header_file
ABHISHEK MAURYA
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
jokersclown57
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
SANTIAGO PABLO ALBERTO
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
forwardcom41
 
Experiment 16 x2 parallel lcd
Experiment   16 x2 parallel lcdExperiment   16 x2 parallel lcd
Experiment 16 x2 parallel lcd
Prashanta Chowdhury
 
Arduino: Arduino lcd
Arduino: Arduino lcdArduino: Arduino lcd
Arduino: Arduino lcd
SANTIAGO PABLO ALBERTO
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 Card
Omar Sanchez
 
Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuenteBlackD10
 
Direct analog
Direct analogDirect analog
Direct analog
srikanthsailu
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignment
babak danyal
 
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
mayank272369
 
LCD Keypad Shield
LCD Keypad ShieldLCD Keypad Shield
LCD Keypad Shield
Raghav Shetty
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
SIGMATAX1
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
footstatus
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
UVSofts Technologies
 
Lcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilogLcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilog
sumedh23
 
ESD -DAY 24.pptx
ESD -DAY 24.pptxESD -DAY 24.pptx
ESD -DAY 24.pptx
BhagvatShukla
 
Arduino LCD 16x2.pptx
Arduino LCD 16x2.pptxArduino LCD 16x2.pptx
Arduino LCD 16x2.pptx
ssuser3d9a7f
 

Similar to Dam gate open close lpc prog (20)

Lcd n PIC16F
Lcd n PIC16FLcd n PIC16F
Lcd n PIC16F
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Atmega lcd programing_with_header_file
Atmega lcd programing_with_header_fileAtmega lcd programing_with_header_file
Atmega lcd programing_with_header_file
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
 
Experiment 16 x2 parallel lcd
Experiment   16 x2 parallel lcdExperiment   16 x2 parallel lcd
Experiment 16 x2 parallel lcd
 
Arduino: Arduino lcd
Arduino: Arduino lcdArduino: Arduino lcd
Arduino: Arduino lcd
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 Card
 
Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuente
 
Direct analog
Direct analogDirect analog
Direct analog
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignment
 
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
 
LCD Keypad Shield
LCD Keypad ShieldLCD Keypad Shield
LCD Keypad Shield
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
 
Lcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilogLcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilog
 
ESD -DAY 24.pptx
ESD -DAY 24.pptxESD -DAY 24.pptx
ESD -DAY 24.pptx
 
Arduino LCD 16x2.pptx
Arduino LCD 16x2.pptxArduino LCD 16x2.pptx
Arduino LCD 16x2.pptx
 

Recently uploaded

weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 

Recently uploaded (20)

weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 

Dam gate open close lpc prog

  • 1. // RS = P1.16 //successful programforarm7 basedfloodalertsystemdate 4/4/2013 for GulabroCOE // EN = P1.17 // D4 = P1.18 // D5 = P1.19 // D6 = P1.20 // D7 = P1.21 #include "LPC214x.H" // LPC2148 MPU Register #include <stdio.h> // Define LCDPinIOMask #define LCD_RS 0x00010000 // P1.16(0000 0000 0000 000x 0000 0000 0000 0000) #define LCD_EN 0x00020000 // P1.17(0000 0000 0000 00x0 0000 0000 0000 0000) #define LCD_D4 0x00040000 // P1.18(0000 0000 0000 0x00 0000 0000 0000 0000) #define LCD_D5 0x00080000 // P1.19(0000 0000 0000 x000 0000 0000 0000 0000) #define LCD_D6 0x00100000 // P1.20(0000 0000 000x 0000 0000 0000 0000 0000) #define LCD_D7 0x00200000 // P1.21(0000 0000 00x0 0000 0000 0000 0000 0000) #define LCD_DATA (LCD_D7|LCD_D6|LCD_D5|LCD_D4) #define LCD_IOALL (LCD_D7|LCD_D6|LCD_D5|LCD_D4|LCD_RS|LCD_EN) #define lcd_rs_set() IOSET1= LCD_RS // RS = 1 (SelectInstruction) #define lcd_rs_clr() IOCLR1= LCD_RS // RS = 0 (SelectData)
  • 2. #define lcd_en_set() IOSET1= LCD_EN // EN = 1 (Enable) #define lcd_en_clr() IOCLR1=LCD_EN // EN = 0 (Disable) // xxxx xxx00000 0000 0000 0000 0000 0000 #define lcd_dir_write() IODIR1|= 0x003F0000 // LCD Data Bus = Write //#define lcd_dir_read() IODIR1&= 0xFFC3FFFF // LCD Data Bus = Read #define lcd_clear() lcd_write_control(0x01) // ClearDisplay #define lcd_cursor_home() lcd_write_control(0x02) // SetCursor= 0 #define lcd_display_on() lcd_write_control(0x0E) // LCD DisplayEnable #define lcd_display_off() lcd_write_control(0x08) // LCD DisplayDisable #define lcd_cursor_blink() lcd_write_control(0x0F) // SetCursor= Blink #define lcd_cursor_on() lcd_write_control(0x0E) // Enable LCD Cursor #define lcd_cursor_off() lcd_write_control(0x0C) // Disable LCDCursor #define lcd_cursor_left() lcd_write_control(0x10) // ShiftLeftCursor #define lcd_cursor_right() lcd_write_control(0x14) // ShiftRightCursor #define lcd_display_sleft() lcd_write_control(0x18) // ShiftLeftDisplay #define lcd_display_sright() lcd_write_control(0x1C) // ShiftRightDisplay /* pototype section */ voidlcd_init(void); // Initial LCD voidlcd_out_data4(unsignedchar); // Strobe 4-BitData to LCD voidlcd_write_byte(unsignedchar); // Write 1 Byte Data to LCD voidlcd_write_control(unsignedchar); // Write Instruction voidlcd_write_ascii(unsignedchar); // Write LCD Display(ASCII)
  • 3. voidgoto_cursor(unsignedchar); // SetPosition Cursor LCD voidlcd_print(unsignedchar*); // PrintDisplayto LCD //char busy_lcd(void); // Read BusyLCD Status voidenable_lcd(void); // Enable Pulse voiddelay(unsignedlongint); // DelayFunction unsignedlongtemp1,temp2; /* Main Program Start Here */ intmain(void) { lcd_init(); // Initial LCD PINSEL0 = PINSEL0 & 0x00000000; //16 bitlowerof port0 PINSEL1 = PINSEL1 & 0x00000000; //16 bithigherof port 0 IODIR0 = IODIR0 |0x00f0FF00; //port0 directionreg32bit PINSEL2 = PINSEL2 & 0xFFFFFFF7; IODIR1 = IODIR1 |0x00FF0000; //Loop PrintMessage to LCD16 x 2 // while(1) // LoopContinue { lcd_write_control(0x01); // Clear Display (ClearDisplay,SetDDRAMAddress=0) goto_cursor(0x00); // Set Cursor Line-1
  • 4. lcd_print("ARM7 Based"); // DisplayLCDLine-1 goto_cursor(0x40); // Set Cursor = Line-2 lcd_print("FloodAlert "); // DisplayLCDLine-2 delay(100000); // Display Delay lcd_write_control(0x01); // Clear Display (ClearDisplay,SetDDRAMAddress=0) goto_cursor(0x00); // SetCursor Line-1 lcd_print(" Systemusing"); // DisplayLCDLine-1 goto_cursor(0x40); // Set Cursor = Line-2 lcd_print("Wireless"); // DisplayLCDLine-2 delay(100000); // Display Delay if( IOPIN0=( IOPIN0& 0x00000004 )) { { temp1 = IOPIN0; temp2 = (temp1& 0x000f0000)>>16 ; if(temp2==0x00000001) { IOSET0 = IOSET0 |0x00001100; //msg1play delay(100000); IOCLR0 = IOCLR0 |0x00000100;
  • 5. lcd_write_control(0x01); // Clear Display (ClearDisplay,SetDDRAMAddress=0) goto_cursor(0x00); // Set Cursor Line-1 lcd_print("FloodWarning"); // DisplayLCDLine-1 delay(100000); // DisplayDelay lcd_write_control(0x01); // Clear Display (ClearDisplay,SetDDRAMAddress=0) goto_cursor(0x00); // Set Cursor Line-1 lcd_print("DAMGATE OPEN "); // DisplayLCDLine-1 delay(100000); // DisplayDelay } if(temp2==0x00000002) { IOSET0 = IOSET0 |0x00001200; //msg2play delay(100000); IOCLR0 = IOCLR0 |0x00000200; } if(temp2==0x00000003) { IOSET0 = IOSET0 |0x00003400; //msg3play delay(100000); IOCLR0 = IOCLR0 |0x00003400;
  • 6. lcd_write_control(0x01); // ClearDisplay (ClearDisplay,SetDDRAMAddress=0) goto_cursor(0x00); // Set Cursor Line-1 lcd_print("NORMALCONDITION "); // DisplayLCDLine-1 delay(100000); // DisplayDelay lcd_write_control(0x01); // Clear Display (ClearDisplay,SetDDRAMAddress=0) goto_cursor(0x00); // Set Cursor Line-1 lcd_print("DAMGATE CLOSE "); // DisplayLCDLine-1 delay(100000); // DisplayDelay } } } } } /****************************/ /* Strobe 4-Bit Data to LCD */ /****************************/ voidlcd_out_data4(unsignedcharval) { IOCLR1 = (LCD_DATA); // Reset4- Bit PinData
  • 7. IOSET1 = (val<<18); // EN,0,RW,RS:DDDD:0000:0000:0000:0000:0000:0000 } /****************************/ /* Write Data 1 Byte to LCD */ /****************************/ voidlcd_write_byte(unsignedcharval) { lcd_out_data4((val>>4)&0x0F); // Strobe 4-BitHigh- Nibble toLCD enable_lcd(); // Enable Pulse lcd_out_data4(val&0x0F); // Strobe 4- Bit Low-Nibble toLCD enable_lcd(); // Enable Pulse delay(100000); //while(busy_lcd()); // WaitLCD Execute Complete } /****************************/ /* Write InstructiontoLCD */ /****************************/
  • 8. voidlcd_write_control(unsignedcharval) { lcd_rs_clr(); // RS = 0 = InstructionSelect lcd_write_byte(val); // Strobe CommandByte } /****************************/ /* Write Data(ASCII) toLCD */ /****************************/ voidlcd_write_ascii(unsignedcharc) { lcd_rs_set(); // RS = 1 = Data Select lcd_write_byte(c); // Strobe 1 Byte to LCD } /*******************************/ /* Initial 4-BitLCD Interface */ /*******************************/ voidlcd_init() { unsignedinti; // LCD Initial DelayCount PINSEL2 = 0x00000000; // GPIO1[31..26] = I/OFunction
  • 9. lcd_dir_write(); // LCD Data Bus= Write for(i=0;i<1000;i++); // Power-OnDelay (15 mS) IOCLR1 = (LCD_IOALL); // Reset (RS,RW,EN,4-BitData) Pin IOSET1 = (LCD_D5|LCD_D4); // DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000 enable_lcd(); // Enable Pulse for(i=0;i<100;i++); // Delay4.1mS IOCLR1 = (LCD_IOALL); // Reset (RS,RW,EN,4-BitData) Pin IOSET1 = (LCD_D5|LCD_D4); // DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000 enable_lcd(); // Enable Pulse for(i=0;i<100;i++); // delay 100uS IOCLR1 = (LCD_IOALL); // Reset (RS,RW,EN,4-BitData) Pin IOSET1 = (LCD_D5|LCD_D4); // DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000 enable_lcd(); // Enable Pulse delay(10000); //while(busy_lcd()); // WaitLCD Execute Complete
  • 10. IOCLR1 = (LCD_IOALL); // Reset (RS,RW,EN,4-BitData) Pin IOSET1 = (LCD_D5); // DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000 enable_lcd(); // Enable Pulse delay(10000); //while(busy_lcd()); // WaitLCD Execute Complete lcd_write_control(0x28); // FunctionSet (DL=0 4-Bit,N=12 Line,F=05X7) lcd_write_control(0x0C); // Displayon/off Control (EntryDisplay,Cursoroff,CursornotBlink) lcd_write_control(0x06); // Entry Mode Set (I/D=1 Increment,S=0CursorShift) lcd_write_control(0x01); // ClearDisplay (ClearDisplay,SetDDRAMAddress=0) for(i=0;i<100000;i++); // WaitCommand Ready } /***************************/ /* Set LCD PositionCursor*/ /***************************/ voidgoto_cursor(unsignedchari) { i |= 0x80; // SetDD-RAMAddressCommand
  • 11. lcd_write_control(i); } /************************************/ /* PrintDisplayData(ASCII) toLCD*/ /************************************/ voidlcd_print(unsignedchar*str) { inti; for(i=0;i<16 && str[i]!=0;i++) // 16 CharacterPrint { lcd_write_ascii(str[i]); // PrintByte to LCD } } /******************/ /* Wait LCD Ready*/ /******************/ /*char busy_lcd(void) { unsignedlongbusy_status; // BusyStatusRead unsignedinti; // Delay Count
  • 12. lcd_dir_read(); // LCD Data Bus = Read lcd_rs_clr(); // InstructionSelect lcd_rw_set(); // Read Direction lcd_en_set(); // Start ReadBusy for(i=0;i<1000;i++); // Delay Before Read busy_status= (IOPIN1&0x80000000); // ReadLCD Data(DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000) if(busy_status==0x80000000) // Read& Check BusyFlag { lcd_en_clr(); // Disable Read lcd_rw_clr(); // Default= Write Direction lcd_dir_write(); // LCD Data Bus = Write return1; // LCD Busy Status } else { lcd_en_clr(); // Disable Read lcd_rw_clr(); // Default= Write Direction lcd_dir_write(); // LCD Data Bus = Write
  • 13. return0; // LCD ReadyStatus } } */ /***********************/ /* Enable Pulse toLCD */ /***********************/ voidenable_lcd(void) // Enable Pulse { unsignedinti; // Delay Count lcd_en_set(); // Enable ON for(i=0;i<400000;i++); lcd_en_clr(); // Enable OFF } /***********************/ /* DelayTime Function*/ /* 1-4294967296 */ /***********************/ voiddelay(unsignedlongintcount1) {
  • 14. while(count1>0) {count1--;} // Loop Decrease Counter }