SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
1. ON OFF LED through a switch?
2. ON OFF LED Sequentially with PORTB
3. Display Seven segments from 0 to 9?
4.
5. read data byte on port C and send it on port B?
6. read data byte on portc and send it on portb in inverted form?
7. out a byte of data 0xAA on portb.f0 serially one bit at a time. LSB should go first
continuously?
8. out a byte of data 0x45 on portb.f0 serially one bit at a time MSB should go first
(continuously)?
9. in byte of data on portb .f0 serially one bit a time continuously MSB Should
come first?
10. in a byte of data through Portb.f0 serially one bit at a time LSB should
come first?
11. ON OFF a 220V bulb through a switch?
12. control the direction of DCMOTOR portC through a switch on Portb?
13. move a stepper motor for 30degree?
14. Design a circuit to control the direction of stepper motor [full torque] .
15. write “ kicsit ” On LCD screen use Any port ?
16. write “kicsit” On LCD screen using port b only?
17. Design a program to of Pressure controller using pressure switch.
18. write a program to count the number of Person Entering In a gate, And display
the result on the screen (LCD);
19. Design a temperature control system for furnace. Two temperature switches are
installed in a furnace to measure the hot and cold of furnace
20. Design a interface of keypad and display on LCD.
21. design the interface of stepper motor to control the direction of stepper motor
with Key pad?
22. Design a interface of stepper motor with microcontroller Degree of circular
motion is Entered from keypad and displayed on LCD
Assignment No 2 Microcontroller
Page | 1
Q .1 Write a program to ON OFF LED trough a switch?
void main ()
{
trisc.f0=0;
trisb.f0=1;
portc.f0=0;
while(1)
{
if(portb.f0==1)
{
portc.f0=1;
}
else
{
portc.f0=0;
}
}
}
Assignment No 2 Microcontroller
Page | 2
Q .2 Write a program to ON OFF LED Sequentially with PORTB.
void main(void)
{
trisb=0x00;
portb=0x00;
while(1)
{
portb.f0=1;
Delay_ms(100);
portb.f0=0;
portb.f1=1;
Delay_ms(100);
portb.f1=0;
portb.f2=1;
Delay_ms(100);
portb.f2=0;
portb.f3=1;
Delay_ms(100);
portb.f3=0;
portb.f4=1;
Delay_ms(100);
portb.f4=0;
portb.f5=1;
Delay_ms(100);
portb.f5=0;
portb.f6=1;
Delay_ms(100);
portb.f6=0;
portb.f7=1;
Delay_ms(100);
portb.f7=0;
}
}
Assignment No 2 Microcontroller
Page | 3
Q. 3 write a program to Display Seven segments from 0 to 9?
void main ()
{
unsigned char n[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
int i;
trisc=0;
portc=0;
while(1)
{
for(i=0;i<10;i++)
{
portc=n[i];
delay_ms(300);
}
}
}
Assignment No 2 Microcontroller
Page | 4
Q5. Write a program to read data byte on port C and send it on port B?
Void main()
{
TRISC=0;
TRISB=1;
While(1){
Portb=portc;
}
}
Assignment No 2 Microcontroller
Page | 5
Q6. Write a program to read data byte on portc and send it on portb in inverted form?
Void main()
{
TRISC=0;
TRISB=1;
While(1){
Port B= ~ port C;
}
}
Assignment No 2 Microcontroller
Page | 6
Q 7 Write a program to out a byte of data 0xAA on portb.f0 serially one bit at a time.
LSB should go first continuously?
void main ()
{
int i=0;
unsigned char a;
unsigned char x=0xaa;
trisb.f0=0;
portb.f0=0;
a=x;
while(1)
{
portb.f0=a;
delay_ms(200);
a=a>>1;
if(i==8)
{
a=x;
i=0;
}
i=i+1;
}}
Assignment No 2 Microcontroller
Page | 7
Q 8 write a program to out a byte of data 0x45 on portb.f0 serially one bit at a time
MSB should go first (continuously)?
void main ()
{
int i=7;
unsigned char a=0x45;
unsigned char x=0x45;
a=x;
trisb.f0=0;
while(1)
{
a=a>>i;
portb.f0=a;
delay_ms(200);
a=x;
i--;
if(i<0)
{
i=7;
}
}
}
Q9 write a program to in byte of data on portb .f0 serially one bit a time continuously
MSB Should come first?
Void main()
{
Unsigned char bitdata;
Int i=0;
TRISB.F0=1;
PORTB.F0=0;
While (i!=8)
{
Bitdata=PORTB.F0;
Bitdata=bitdata<<1;
I++;
}
}
Q10 .write a program to in a byte of data through Portb.f0 serially one bit at a time LSB
should come first?
Void main()
{
TRISB=1;
PORTB=0;
While(i!=8)
{
Bitdata=PORTB.F0; // Lsb come first
Bitdata=Bitdata<<1; //at the end we get inverted form
Assignment No 2 Microcontroller
Page | 8
I++;
}
I=0;
Unsigned char temp;
While(i!=8)
{
Temp=Bitdata;
Temp=Temp<<1;
Bitdata=Bitdata>>1;
}
}
Q 11write a program to ON OFF a 220V bulb through a switch?
void main()
{
trisc=0;
portc=0;
trisb.f0=1;
while(1)
{
if(portb.f0==1)
{
portc.f0=1;
}
else
portc.f0=0;
}
}
Assignment No 2 Microcontroller
Page | 9
Q 12 writes a program to control the direction of DCMOTOR portC through a switch
on Portb?
#define sw1 portb.f0
#define sw2 portb.f1
#define ON 1
#define OFF 0
void main()
{
TRISB=1;
portb=0;
TRISC=0;
while (1)
{
if(sw1==ON)
{ portc.f3=OFF;
portc.f1=OFF;
Delay_ms(10);
portc.f0=ON;
portc.f2=ON;
delay_ms(200);
}
if(sw2==ON)
{
portc.f0=OFF;
portc.f2=OFF;
delay_ms(10);
portc.f3=ON;
portc.f1=ON;
delay_ms(100);
}
}
}
C0 C1 C2 C3 DIRECTION
1 0 1 0 CLOCKWICE
0 1 0 1 ANTICLOCKWISE
Assignment No 2 Microcontroller
Page | 10
Q13 write a program to move a stepper motor for 30degree?
Speciation of stepper motor .1deg/step
Calculation
.1 degree = 1 step
1deg =1/.1 step
30 deg = 30/0.1step => 300 steps 300 / 4 =75
Void main ()
{
trisc=0;
portc=0;
inti,j=0;
unsigned char a[4]={0x01,0x02,0x04,0x08};
while(1)
{
for(i=0;i<75;i++)
{
for(j=0;j<4;j++)
{
portc=a[j];
delay_ms(100);
//portc=0;
}
//portc=0;
}
}
}
Assignment No 2 Microcontroller
Page | 11
Q14 Design a circuit to control the direction of stepper motor [full torque] .
void step(unsigned char x)
{
portc=x;
delay_ms(200);
//portc=0x00;
}
void step1(unsigned char y)
{
portc=y;
delay_ms(200);
//portc=0x00;
}
void main()
{
unsigned char n[4]= {0x01,0x02,0x04,0x08};
unsigned char u[4]= {0x08,0x04,0x02,0x01};
unsignedinti,j,k,l;
trisc=0;
portc=0;
while(1){
for(i=1; i<5; i++)
Assignment No 2 Microcontroller
Page | 12
{
for(j=0; j<4; j++)
{
step(n[j]);
}
}
delay_ms(100);
portc=0;
for(k=1; k<5; k++)
{
for(l=0; l<4; l++)
{
step1(u[l]);
}
}
}
}
Q15 write a program to write “ kicsit ” On LCD screen use Any port ?
#define datalineportd
#define rs portc.f0
#define e portc.f1
void command(unsigned char x)
{
e=0;
rs=0;
dataline=x;
e=1;
Assignment No 2 Microcontroller
Page | 13
delay_ms(50);
e=0;
}
void data(unsigned char y)
{
e=0;
rs=1;
dataline=y;
e=1;
delay_ms(50);
e=0;
}
void main()
{
trisd=0x00;
trisc.f0=0;
trisc.f1=0;
command(0x38);
command(0x06);
command(0x0c);
command(0x01);
while(1)
{
command(0x80);
data('B');
command(0xc0);
data('A');
command(0x82);
data('B');
command(0xc2);
data('R');
command(0x84);
data('U');
command(0x85);
data(' ');
command(0x86);
data(' ');
Assignment No 2 Microcontroller
Page | 14
command(0x87);
data('D');
command(0x88);
data('O');
command(0x89);
data('N');
}
}
Q 16 writes a program to write “kicsit” On LCD screen using port b only?
[We solve it through command]
void main(void)
{
TRISD=0x00;
LCD_Init(&PORTD);
Lcd_Cmd(Lcd_Clear);
Lcd_Out(1,1,"KICSIT");
While(1){
}
}
Q 17 Design a program to of Pressure controller using pressure switch.
Specification of Pressure switch
100 baar =break (OFF =0)
50 baar =Make (ON 1)
sbit LCD_RS at RD3_bit;
sbit LCD_EN at RD2_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D4 at RD4_bit;
// Pin direction
sbitLCD_RS_Direction at TRISD3_bit;
sbitLCD_EN_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD7_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
int flag=0;
void interrupt(void);
void main() {
char key;
INTCON=0x90;
//INTCON3=0x08;
INTCON2.INTEDG0=1;
Assignment No 2 Microcontroller
Page | 15
//INTCON2.INTEDG1=1;
TRISB=0X0F;
TRISC=0X00;
//trisd=0;
//TRISC=0;
Lcd_Init();
//Lcd_Out(1,4,"Well Come");
while(1)
{
}
}
void interrupt(void)
{
if(INTCON.INT0IF==1 && flag==0)
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Motor is OFF");
//Lcd_Out(2,4,scount );
INTCON.INT0IF=0;
INTCON2.INTEDG0=0;
flag=1;
PORTC.f0=0;
// PORTC.F0=~PORTC.F0;
}
if(INTCON.INT0IF==1 && flag==1)
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Motor is ON");
//Lcd_Out(2,4,scount );
PORTC.f0=1;
INTCON.INT0IF=0;
flag=0;
INTCON2.INTEDG0=1;
// PORTC.F0=~PORTC.F0;
}
}
Assignment No 2 Microcontroller
Page | 16
Q18 write a program to count the number of Person Entering In a gate, And display
the result on the screen (LCD);
sbit LCD_RS at RD3_bit;
sbit LCD_EN at RD2_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D4 at RD4_bit;
// Pin direction
sbitLCD_RS_Direction at TRISD3_bit;
sbitLCD_EN_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD7_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
int count=0;
charscount[10];
void interrupt(void);
void main() {
char key;
INTCON=0x90;
INTCON2.INTEDG0=1;
TRISB=0X0F;
//TRISC=0X00;
//trisd=0;
//TRISC=0;
Lcd_Init();
//Lcd_Out(1,4,"Well Come");
Assignment No 2 Microcontroller
Page | 17
while(1)
{
}
}
void interrupt(void)
{
if(INTCON.INT0IF)
{
count++;
IntToStr(count,scount);
Lcd_Out(1,1,"Count =");
Lcd_Out(2,4,scount );
INTCON.INT0IF=0;
// PORTC.F0=~PORTC.F0;
}
}
Q19 Design a temperature control system for furnace. Two temperature switches are
installed in a furnace to measure the hot and cold of furnace
HOT>100 output = 1;
Cold<35 output=1;
sbit LCD_RS at RD3_bit;
sbit LCD_EN at RD2_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D4 at RD4_bit;
// Pin direction
sbitLCD_RS_Direction at TRISD3_bit;
sbitLCD_EN_Direction at TRISD2_bit;
Assignment No 2 Microcontroller
Page | 18
sbit LCD_D7_Direction at TRISD7_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
void interrupt(void);
void main() {
char key;
INTCON=0x90;
INTCON3=0x08;
INTCON2.INTEDG0=1;
INTCON2.INTEDG1=1;
TRISB=0X0F;
TRISC=0X00;
//trisd=0;
//TRISC=0;
Lcd_Init();
//Lcd_Out(1,4,"Well Come");
while(1)
{
}
}
void interrupt(void)
{
if(INTCON.INT0IF)
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Motor is OFF");
//Lcd_Out(2,4,scount );
INTCON.INT0IF=0;
PORTC=0X00;
// PORTC.F0=~PORTC.F0;
}
if(INTCON3.INT1IF)
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Motor is ON");
//Lcd_Out(2,4,scount );
PORTC=0XFF;
INTCON3.INT1IF=0;
// PORTC.F0=~PORTC.F0;
}
}
Assignment No 2 Microcontroller
Page | 19
Q20 Design a interface of keypad and display on LCD.
Q21 design the interface of stepper motor to control the direction of stepper
motor with Key pad?
1 > Anticlockwise
2> Clockwise
sbit LCD_RS at RD3_bit;
sbit LCD_EN at RD2_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D4 at RD4_bit;
// Pin direction
sbitLCD_RS_Direction at TRISD3_bit;
sbitLCD_EN_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD7_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
clockmotor();
void main() {
char key;
TRISB=0XF0;
TRISC=0X00;
trisd=0;
Lcd_Init();
Lcd_Out(1,4,"Well Come");
//Lcd_Out(2,1,"Press Any Key");
Assignment No 2 Microcontroller
Page | 20
Lcd_cmd(_Lcd_clear);
m:
Lcd_Out(1,1,"1 : For ClockWise :");
Lcd_Out(2,1,"2 : For AntiClockWise :");
while(1)
{
portb=0xf1;
if(portb.f4==1)
{
//Lcd_Out(1,6,"7");
goto m;
}portb=0xf4;
if(portb.f4==1)
{
//Lcd_Out(1,6,"1");
Lcd_cmd(_lcd_clear);
lcd_out(1,1,"7 : To main");
Lcd_out(2,1,"Clockwise");
while(1){
PORTC.F0 = 1;
delay_ms(50);
PORTC.F0 = 0;
PORTC.F1 = 1;
delay_ms(50);
PORTC.F1 = 0;
PORTC.F2 = 1;
delay_ms(50);
PORTC.F2 = 0;
PORTC.F3 = 1;
DELAY_MS(50);
PORTC.F3 = 0;
portb=0xf1;
if(portb.f4==1)
{
//Lcd_Out(1,6,"7");
goto m;
}
}
}
if(portb.f5==1)
{
Lcd_cmd(_lcd_clear);
lcd_out(1,1,"7 : To main");
Lcd_Out(2,1,"AntiClockwise");
while(1){
PORTC.F3 = 1;
Assignment No 2 Microcontroller
Page | 21
delay_ms(50);
PORTC.F3 = 0;
PORTC.F2 = 1;
delay_ms(50);
PORTC.F2 = 0;
PORTC.F1 = 1;
delay_ms(50);
PORTC.F1 = 0;
PORTC.F0 = 1;
DELAY_MS(50);
PORTC.F0 = 0;
portb=0xf1;
if(portb.f4==1)
{
//Lcd_Out(1,6,"7");
goto m;
}}
}
} }
Q22 Design a interface of stepper motor with microcontroller Degree of circular motion
is Entered from keypad and displayed on LCD

Mais conteúdo relacionado

Mais procurados

Handling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsHandling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsCorrado Santoro
 
Lathe Spindle Sensor
Lathe Spindle SensorLathe Spindle Sensor
Lathe Spindle SensorJoeCritt
 
22 microcontroller programs
22 microcontroller programs22 microcontroller programs
22 microcontroller programsbabak danyal
 
Uart VHDL RTL design tutorial
Uart VHDL RTL design tutorialUart VHDL RTL design tutorial
Uart VHDL RTL design tutorialNabil Chouba
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 CardOmar Sanchez
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manualtwinkleratna
 
74LS47 / DM74LS47 Datasheet PDF
74LS47 / DM74LS47 Datasheet PDF74LS47 / DM74LS47 Datasheet PDF
74LS47 / DM74LS47 Datasheet PDFDatasheet
 
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 verilogsumedh23
 

Mais procurados (20)

Handling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsHandling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUs
 
Lathe Spindle Sensor
Lathe Spindle SensorLathe Spindle Sensor
Lathe Spindle Sensor
 
22 microcontroller programs
22 microcontroller programs22 microcontroller programs
22 microcontroller programs
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Ports 0f 8051
Ports 0f 8051Ports 0f 8051
Ports 0f 8051
 
Uart
UartUart
Uart
 
I/O Ports
I/O Ports I/O Ports
I/O Ports
 
Ket noi sungrow
Ket noi sungrowKet noi sungrow
Ket noi sungrow
 
Uart VHDL RTL design tutorial
Uart VHDL RTL design tutorialUart VHDL RTL design tutorial
Uart VHDL RTL design tutorial
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 Card
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
 
74LS47 / DM74LS47 Datasheet PDF
74LS47 / DM74LS47 Datasheet PDF74LS47 / DM74LS47 Datasheet PDF
74LS47 / DM74LS47 Datasheet PDF
 
UART MCU
UART MCUUART MCU
UART MCU
 
input
inputinput
input
 
Módulo adc 18f4550
Módulo adc   18f4550Módulo adc   18f4550
Módulo adc 18f4550
 
Lcd interfacing
Lcd interfacingLcd interfacing
Lcd interfacing
 
8051 ports
8051 ports8051 ports
8051 ports
 
I o ports.ppt
I o ports.pptI o ports.ppt
I o ports.ppt
 
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
 
Atmega16
Atmega16Atmega16
Atmega16
 

Semelhante a 22 Microcontroller Programs

Code for auto intensity control of street lightsCode for this pro.pdf
Code for auto intensity control of street lightsCode for this pro.pdfCode for auto intensity control of street lightsCode for this pro.pdf
Code for auto intensity control of street lightsCode for this pro.pdfannaipowerelectronic
 
Microcontroladores: Programación con microcontrolador PIC
Microcontroladores: Programación con microcontrolador PICMicrocontroladores: Programación con microcontrolador PIC
Microcontroladores: Programación con microcontrolador PICSANTIAGO PABLO ALBERTO
 
Programming with PIC microcontroller
Programming with PIC microcontroller Programming with PIC microcontroller
Programming with PIC microcontroller Raghav Shetty
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prognikhil dixit
 
2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdf2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdfVNEX
 
Power the world with mbed LPC1768
Power the world with mbed LPC1768Power the world with mbed LPC1768
Power the world with mbed LPC1768yoonghm
 
Untitled 1
Untitled 1Untitled 1
Untitled 1lakachew
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051) vijaydeepakg
 
Embedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programmingEmbedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programmingIkhwan_Fakrudin
 
Intro2 Robotic With Pic18
Intro2 Robotic With Pic18Intro2 Robotic With Pic18
Intro2 Robotic With Pic18Moayadhn
 
Programming A Robot Using
Programming A Robot UsingProgramming A Robot Using
Programming A Robot UsingSpitiq
 
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 recordG Lemuel George
 
Write ASSEMBLY code to implement the following Initialize PORTB for.docx
 Write ASSEMBLY code to implement the following  Initialize PORTB for.docx Write ASSEMBLY code to implement the following  Initialize PORTB for.docx
Write ASSEMBLY code to implement the following Initialize PORTB for.docxajoy21
 
Seven Segment Displau
Seven Segment DisplauSeven Segment Displau
Seven Segment DisplauMishu Rana
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Omkar Rane
 

Semelhante a 22 Microcontroller Programs (20)

Code for auto intensity control of street lightsCode for this pro.pdf
Code for auto intensity control of street lightsCode for this pro.pdfCode for auto intensity control of street lightsCode for this pro.pdf
Code for auto intensity control of street lightsCode for this pro.pdf
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Program LCD ARM
Program LCD ARMProgram LCD ARM
Program LCD ARM
 
PIC Microcontrollers.pdf
PIC Microcontrollers.pdfPIC Microcontrollers.pdf
PIC Microcontrollers.pdf
 
PIC Microcontrollers.pdf
PIC Microcontrollers.pdfPIC Microcontrollers.pdf
PIC Microcontrollers.pdf
 
Microcontroladores: Programación con microcontrolador PIC
Microcontroladores: Programación con microcontrolador PICMicrocontroladores: Programación con microcontrolador PIC
Microcontroladores: Programación con microcontrolador PIC
 
Programming with PIC microcontroller
Programming with PIC microcontroller Programming with PIC microcontroller
Programming with PIC microcontroller
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prog
 
Lec12
Lec12Lec12
Lec12
 
2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdf2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdf
 
Power the world with mbed LPC1768
Power the world with mbed LPC1768Power the world with mbed LPC1768
Power the world with mbed LPC1768
 
Untitled 1
Untitled 1Untitled 1
Untitled 1
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
 
Embedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programmingEmbedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programming
 
Intro2 Robotic With Pic18
Intro2 Robotic With Pic18Intro2 Robotic With Pic18
Intro2 Robotic With Pic18
 
Programming A Robot Using
Programming A Robot UsingProgramming A Robot Using
Programming A Robot Using
 
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
 
Write ASSEMBLY code to implement the following Initialize PORTB for.docx
 Write ASSEMBLY code to implement the following  Initialize PORTB for.docx Write ASSEMBLY code to implement the following  Initialize PORTB for.docx
Write ASSEMBLY code to implement the following Initialize PORTB for.docx
 
Seven Segment Displau
Seven Segment DisplauSeven Segment Displau
Seven Segment Displau
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148
 

Mais de babak danyal

Easy Steps to implement UDP Server and Client Sockets
Easy Steps to implement UDP Server and Client SocketsEasy Steps to implement UDP Server and Client Sockets
Easy Steps to implement UDP Server and Client Socketsbabak danyal
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streamsbabak danyal
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Javababak danyal
 
block ciphers and the des
block ciphers and the desblock ciphers and the des
block ciphers and the desbabak danyal
 
key distribution in network security
key distribution in network securitykey distribution in network security
key distribution in network securitybabak danyal
 
Lecture10 Signal and Systems
Lecture10 Signal and SystemsLecture10 Signal and Systems
Lecture10 Signal and Systemsbabak danyal
 
Lecture8 Signal and Systems
Lecture8 Signal and SystemsLecture8 Signal and Systems
Lecture8 Signal and Systemsbabak danyal
 
Lecture7 Signal and Systems
Lecture7 Signal and SystemsLecture7 Signal and Systems
Lecture7 Signal and Systemsbabak danyal
 
Lecture6 Signal and Systems
Lecture6 Signal and SystemsLecture6 Signal and Systems
Lecture6 Signal and Systemsbabak danyal
 
Lecture5 Signal and Systems
Lecture5 Signal and SystemsLecture5 Signal and Systems
Lecture5 Signal and Systemsbabak danyal
 
Lecture4 Signal and Systems
Lecture4  Signal and SystemsLecture4  Signal and Systems
Lecture4 Signal and Systemsbabak danyal
 
Lecture3 Signal and Systems
Lecture3 Signal and SystemsLecture3 Signal and Systems
Lecture3 Signal and Systemsbabak danyal
 
Lecture2 Signal and Systems
Lecture2 Signal and SystemsLecture2 Signal and Systems
Lecture2 Signal and Systemsbabak danyal
 
Lecture1 Intro To Signa
Lecture1 Intro To SignaLecture1 Intro To Signa
Lecture1 Intro To Signababak danyal
 
Lecture9 Signal and Systems
Lecture9 Signal and SystemsLecture9 Signal and Systems
Lecture9 Signal and Systemsbabak danyal
 
Cns 13f-lec03- Classical Encryption Techniques
Cns 13f-lec03- Classical Encryption TechniquesCns 13f-lec03- Classical Encryption Techniques
Cns 13f-lec03- Classical Encryption Techniquesbabak danyal
 
Classical Encryption Techniques in Network Security
Classical Encryption Techniques in Network SecurityClassical Encryption Techniques in Network Security
Classical Encryption Techniques in Network Securitybabak danyal
 

Mais de babak danyal (20)

applist
applistapplist
applist
 
Easy Steps to implement UDP Server and Client Sockets
Easy Steps to implement UDP Server and Client SocketsEasy Steps to implement UDP Server and Client Sockets
Easy Steps to implement UDP Server and Client Sockets
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Java
 
Tcp sockets
Tcp socketsTcp sockets
Tcp sockets
 
block ciphers and the des
block ciphers and the desblock ciphers and the des
block ciphers and the des
 
key distribution in network security
key distribution in network securitykey distribution in network security
key distribution in network security
 
Lecture10 Signal and Systems
Lecture10 Signal and SystemsLecture10 Signal and Systems
Lecture10 Signal and Systems
 
Lecture8 Signal and Systems
Lecture8 Signal and SystemsLecture8 Signal and Systems
Lecture8 Signal and Systems
 
Lecture7 Signal and Systems
Lecture7 Signal and SystemsLecture7 Signal and Systems
Lecture7 Signal and Systems
 
Lecture6 Signal and Systems
Lecture6 Signal and SystemsLecture6 Signal and Systems
Lecture6 Signal and Systems
 
Lecture5 Signal and Systems
Lecture5 Signal and SystemsLecture5 Signal and Systems
Lecture5 Signal and Systems
 
Lecture4 Signal and Systems
Lecture4  Signal and SystemsLecture4  Signal and Systems
Lecture4 Signal and Systems
 
Lecture3 Signal and Systems
Lecture3 Signal and SystemsLecture3 Signal and Systems
Lecture3 Signal and Systems
 
Lecture2 Signal and Systems
Lecture2 Signal and SystemsLecture2 Signal and Systems
Lecture2 Signal and Systems
 
Lecture1 Intro To Signa
Lecture1 Intro To SignaLecture1 Intro To Signa
Lecture1 Intro To Signa
 
Lecture9 Signal and Systems
Lecture9 Signal and SystemsLecture9 Signal and Systems
Lecture9 Signal and Systems
 
Lecture9
Lecture9Lecture9
Lecture9
 
Cns 13f-lec03- Classical Encryption Techniques
Cns 13f-lec03- Classical Encryption TechniquesCns 13f-lec03- Classical Encryption Techniques
Cns 13f-lec03- Classical Encryption Techniques
 
Classical Encryption Techniques in Network Security
Classical Encryption Techniques in Network SecurityClassical Encryption Techniques in Network Security
Classical Encryption Techniques in Network Security
 

Último

Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfMohonDas
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxSlides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxCapitolTechU
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...CaraSkikne1
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxDr. Asif Anas
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashasashalaycock03
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Dr. Asif Anas
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceApostolos Syropoulos
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?TechSoup
 
Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxraviapr7
 
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTDR. SNEHA NAIR
 
Optical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxOptical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxPurva Nikam
 

Último (20)

Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdf
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxSlides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptx
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sasha
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial Intelligence
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?
 
Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptx
 
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
Optical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxOptical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptx
 

22 Microcontroller Programs

  • 1. 1. ON OFF LED through a switch? 2. ON OFF LED Sequentially with PORTB 3. Display Seven segments from 0 to 9? 4. 5. read data byte on port C and send it on port B? 6. read data byte on portc and send it on portb in inverted form? 7. out a byte of data 0xAA on portb.f0 serially one bit at a time. LSB should go first continuously? 8. out a byte of data 0x45 on portb.f0 serially one bit at a time MSB should go first (continuously)? 9. in byte of data on portb .f0 serially one bit a time continuously MSB Should come first? 10. in a byte of data through Portb.f0 serially one bit at a time LSB should come first? 11. ON OFF a 220V bulb through a switch? 12. control the direction of DCMOTOR portC through a switch on Portb? 13. move a stepper motor for 30degree? 14. Design a circuit to control the direction of stepper motor [full torque] . 15. write “ kicsit ” On LCD screen use Any port ? 16. write “kicsit” On LCD screen using port b only? 17. Design a program to of Pressure controller using pressure switch. 18. write a program to count the number of Person Entering In a gate, And display the result on the screen (LCD); 19. Design a temperature control system for furnace. Two temperature switches are installed in a furnace to measure the hot and cold of furnace 20. Design a interface of keypad and display on LCD. 21. design the interface of stepper motor to control the direction of stepper motor with Key pad? 22. Design a interface of stepper motor with microcontroller Degree of circular motion is Entered from keypad and displayed on LCD
  • 2. Assignment No 2 Microcontroller Page | 1 Q .1 Write a program to ON OFF LED trough a switch? void main () { trisc.f0=0; trisb.f0=1; portc.f0=0; while(1) { if(portb.f0==1) { portc.f0=1; } else { portc.f0=0; } } }
  • 3. Assignment No 2 Microcontroller Page | 2 Q .2 Write a program to ON OFF LED Sequentially with PORTB. void main(void) { trisb=0x00; portb=0x00; while(1) { portb.f0=1; Delay_ms(100); portb.f0=0; portb.f1=1; Delay_ms(100); portb.f1=0; portb.f2=1; Delay_ms(100); portb.f2=0; portb.f3=1; Delay_ms(100); portb.f3=0; portb.f4=1; Delay_ms(100); portb.f4=0; portb.f5=1; Delay_ms(100); portb.f5=0; portb.f6=1; Delay_ms(100); portb.f6=0; portb.f7=1; Delay_ms(100); portb.f7=0; } }
  • 4. Assignment No 2 Microcontroller Page | 3 Q. 3 write a program to Display Seven segments from 0 to 9? void main () { unsigned char n[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; int i; trisc=0; portc=0; while(1) { for(i=0;i<10;i++) { portc=n[i]; delay_ms(300); } } }
  • 5. Assignment No 2 Microcontroller Page | 4 Q5. Write a program to read data byte on port C and send it on port B? Void main() { TRISC=0; TRISB=1; While(1){ Portb=portc; } }
  • 6. Assignment No 2 Microcontroller Page | 5 Q6. Write a program to read data byte on portc and send it on portb in inverted form? Void main() { TRISC=0; TRISB=1; While(1){ Port B= ~ port C; } }
  • 7. Assignment No 2 Microcontroller Page | 6 Q 7 Write a program to out a byte of data 0xAA on portb.f0 serially one bit at a time. LSB should go first continuously? void main () { int i=0; unsigned char a; unsigned char x=0xaa; trisb.f0=0; portb.f0=0; a=x; while(1) { portb.f0=a; delay_ms(200); a=a>>1; if(i==8) { a=x; i=0; } i=i+1; }}
  • 8. Assignment No 2 Microcontroller Page | 7 Q 8 write a program to out a byte of data 0x45 on portb.f0 serially one bit at a time MSB should go first (continuously)? void main () { int i=7; unsigned char a=0x45; unsigned char x=0x45; a=x; trisb.f0=0; while(1) { a=a>>i; portb.f0=a; delay_ms(200); a=x; i--; if(i<0) { i=7; } } } Q9 write a program to in byte of data on portb .f0 serially one bit a time continuously MSB Should come first? Void main() { Unsigned char bitdata; Int i=0; TRISB.F0=1; PORTB.F0=0; While (i!=8) { Bitdata=PORTB.F0; Bitdata=bitdata<<1; I++; } } Q10 .write a program to in a byte of data through Portb.f0 serially one bit at a time LSB should come first? Void main() { TRISB=1; PORTB=0; While(i!=8) { Bitdata=PORTB.F0; // Lsb come first Bitdata=Bitdata<<1; //at the end we get inverted form
  • 9. Assignment No 2 Microcontroller Page | 8 I++; } I=0; Unsigned char temp; While(i!=8) { Temp=Bitdata; Temp=Temp<<1; Bitdata=Bitdata>>1; } } Q 11write a program to ON OFF a 220V bulb through a switch? void main() { trisc=0; portc=0; trisb.f0=1; while(1) { if(portb.f0==1) { portc.f0=1; } else portc.f0=0; } }
  • 10. Assignment No 2 Microcontroller Page | 9 Q 12 writes a program to control the direction of DCMOTOR portC through a switch on Portb? #define sw1 portb.f0 #define sw2 portb.f1 #define ON 1 #define OFF 0 void main() { TRISB=1; portb=0; TRISC=0; while (1) { if(sw1==ON) { portc.f3=OFF; portc.f1=OFF; Delay_ms(10); portc.f0=ON; portc.f2=ON; delay_ms(200); } if(sw2==ON) { portc.f0=OFF; portc.f2=OFF; delay_ms(10); portc.f3=ON; portc.f1=ON; delay_ms(100); } } } C0 C1 C2 C3 DIRECTION 1 0 1 0 CLOCKWICE 0 1 0 1 ANTICLOCKWISE
  • 11. Assignment No 2 Microcontroller Page | 10 Q13 write a program to move a stepper motor for 30degree? Speciation of stepper motor .1deg/step Calculation .1 degree = 1 step 1deg =1/.1 step 30 deg = 30/0.1step => 300 steps 300 / 4 =75 Void main () { trisc=0; portc=0; inti,j=0; unsigned char a[4]={0x01,0x02,0x04,0x08}; while(1) { for(i=0;i<75;i++) { for(j=0;j<4;j++) { portc=a[j]; delay_ms(100); //portc=0; } //portc=0; } } }
  • 12. Assignment No 2 Microcontroller Page | 11 Q14 Design a circuit to control the direction of stepper motor [full torque] . void step(unsigned char x) { portc=x; delay_ms(200); //portc=0x00; } void step1(unsigned char y) { portc=y; delay_ms(200); //portc=0x00; } void main() { unsigned char n[4]= {0x01,0x02,0x04,0x08}; unsigned char u[4]= {0x08,0x04,0x02,0x01}; unsignedinti,j,k,l; trisc=0; portc=0; while(1){ for(i=1; i<5; i++)
  • 13. Assignment No 2 Microcontroller Page | 12 { for(j=0; j<4; j++) { step(n[j]); } } delay_ms(100); portc=0; for(k=1; k<5; k++) { for(l=0; l<4; l++) { step1(u[l]); } } } } Q15 write a program to write “ kicsit ” On LCD screen use Any port ? #define datalineportd #define rs portc.f0 #define e portc.f1 void command(unsigned char x) { e=0; rs=0; dataline=x; e=1;
  • 14. Assignment No 2 Microcontroller Page | 13 delay_ms(50); e=0; } void data(unsigned char y) { e=0; rs=1; dataline=y; e=1; delay_ms(50); e=0; } void main() { trisd=0x00; trisc.f0=0; trisc.f1=0; command(0x38); command(0x06); command(0x0c); command(0x01); while(1) { command(0x80); data('B'); command(0xc0); data('A'); command(0x82); data('B'); command(0xc2); data('R'); command(0x84); data('U'); command(0x85); data(' '); command(0x86); data(' ');
  • 15. Assignment No 2 Microcontroller Page | 14 command(0x87); data('D'); command(0x88); data('O'); command(0x89); data('N'); } } Q 16 writes a program to write “kicsit” On LCD screen using port b only? [We solve it through command] void main(void) { TRISD=0x00; LCD_Init(&PORTD); Lcd_Cmd(Lcd_Clear); Lcd_Out(1,1,"KICSIT"); While(1){ } } Q 17 Design a program to of Pressure controller using pressure switch. Specification of Pressure switch 100 baar =break (OFF =0) 50 baar =Make (ON 1) sbit LCD_RS at RD3_bit; sbit LCD_EN at RD2_bit; sbit LCD_D7 at RD7_bit; sbit LCD_D6 at RD6_bit; sbit LCD_D5 at RD5_bit; sbit LCD_D4 at RD4_bit; // Pin direction sbitLCD_RS_Direction at TRISD3_bit; sbitLCD_EN_Direction at TRISD2_bit; sbit LCD_D7_Direction at TRISD7_bit; sbit LCD_D6_Direction at TRISD6_bit; sbit LCD_D5_Direction at TRISD5_bit; sbit LCD_D4_Direction at TRISD4_bit; int flag=0; void interrupt(void); void main() { char key; INTCON=0x90; //INTCON3=0x08; INTCON2.INTEDG0=1;
  • 16. Assignment No 2 Microcontroller Page | 15 //INTCON2.INTEDG1=1; TRISB=0X0F; TRISC=0X00; //trisd=0; //TRISC=0; Lcd_Init(); //Lcd_Out(1,4,"Well Come"); while(1) { } } void interrupt(void) { if(INTCON.INT0IF==1 && flag==0) { Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1,1,"Motor is OFF"); //Lcd_Out(2,4,scount ); INTCON.INT0IF=0; INTCON2.INTEDG0=0; flag=1; PORTC.f0=0; // PORTC.F0=~PORTC.F0; } if(INTCON.INT0IF==1 && flag==1) { Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1,1,"Motor is ON"); //Lcd_Out(2,4,scount ); PORTC.f0=1; INTCON.INT0IF=0; flag=0; INTCON2.INTEDG0=1; // PORTC.F0=~PORTC.F0; } }
  • 17. Assignment No 2 Microcontroller Page | 16 Q18 write a program to count the number of Person Entering In a gate, And display the result on the screen (LCD); sbit LCD_RS at RD3_bit; sbit LCD_EN at RD2_bit; sbit LCD_D7 at RD7_bit; sbit LCD_D6 at RD6_bit; sbit LCD_D5 at RD5_bit; sbit LCD_D4 at RD4_bit; // Pin direction sbitLCD_RS_Direction at TRISD3_bit; sbitLCD_EN_Direction at TRISD2_bit; sbit LCD_D7_Direction at TRISD7_bit; sbit LCD_D6_Direction at TRISD6_bit; sbit LCD_D5_Direction at TRISD5_bit; sbit LCD_D4_Direction at TRISD4_bit; int count=0; charscount[10]; void interrupt(void); void main() { char key; INTCON=0x90; INTCON2.INTEDG0=1; TRISB=0X0F; //TRISC=0X00; //trisd=0; //TRISC=0; Lcd_Init(); //Lcd_Out(1,4,"Well Come");
  • 18. Assignment No 2 Microcontroller Page | 17 while(1) { } } void interrupt(void) { if(INTCON.INT0IF) { count++; IntToStr(count,scount); Lcd_Out(1,1,"Count ="); Lcd_Out(2,4,scount ); INTCON.INT0IF=0; // PORTC.F0=~PORTC.F0; } } Q19 Design a temperature control system for furnace. Two temperature switches are installed in a furnace to measure the hot and cold of furnace HOT>100 output = 1; Cold<35 output=1; sbit LCD_RS at RD3_bit; sbit LCD_EN at RD2_bit; sbit LCD_D7 at RD7_bit; sbit LCD_D6 at RD6_bit; sbit LCD_D5 at RD5_bit; sbit LCD_D4 at RD4_bit; // Pin direction sbitLCD_RS_Direction at TRISD3_bit; sbitLCD_EN_Direction at TRISD2_bit;
  • 19. Assignment No 2 Microcontroller Page | 18 sbit LCD_D7_Direction at TRISD7_bit; sbit LCD_D6_Direction at TRISD6_bit; sbit LCD_D5_Direction at TRISD5_bit; sbit LCD_D4_Direction at TRISD4_bit; void interrupt(void); void main() { char key; INTCON=0x90; INTCON3=0x08; INTCON2.INTEDG0=1; INTCON2.INTEDG1=1; TRISB=0X0F; TRISC=0X00; //trisd=0; //TRISC=0; Lcd_Init(); //Lcd_Out(1,4,"Well Come"); while(1) { } } void interrupt(void) { if(INTCON.INT0IF) { Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1,1,"Motor is OFF"); //Lcd_Out(2,4,scount ); INTCON.INT0IF=0; PORTC=0X00; // PORTC.F0=~PORTC.F0; } if(INTCON3.INT1IF) { Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1,1,"Motor is ON"); //Lcd_Out(2,4,scount ); PORTC=0XFF; INTCON3.INT1IF=0; // PORTC.F0=~PORTC.F0; } }
  • 20. Assignment No 2 Microcontroller Page | 19 Q20 Design a interface of keypad and display on LCD. Q21 design the interface of stepper motor to control the direction of stepper motor with Key pad? 1 > Anticlockwise 2> Clockwise sbit LCD_RS at RD3_bit; sbit LCD_EN at RD2_bit; sbit LCD_D7 at RD7_bit; sbit LCD_D6 at RD6_bit; sbit LCD_D5 at RD5_bit; sbit LCD_D4 at RD4_bit; // Pin direction sbitLCD_RS_Direction at TRISD3_bit; sbitLCD_EN_Direction at TRISD2_bit; sbit LCD_D7_Direction at TRISD7_bit; sbit LCD_D6_Direction at TRISD6_bit; sbit LCD_D5_Direction at TRISD5_bit; sbit LCD_D4_Direction at TRISD4_bit; clockmotor(); void main() { char key; TRISB=0XF0; TRISC=0X00; trisd=0; Lcd_Init(); Lcd_Out(1,4,"Well Come"); //Lcd_Out(2,1,"Press Any Key");
  • 21. Assignment No 2 Microcontroller Page | 20 Lcd_cmd(_Lcd_clear); m: Lcd_Out(1,1,"1 : For ClockWise :"); Lcd_Out(2,1,"2 : For AntiClockWise :"); while(1) { portb=0xf1; if(portb.f4==1) { //Lcd_Out(1,6,"7"); goto m; }portb=0xf4; if(portb.f4==1) { //Lcd_Out(1,6,"1"); Lcd_cmd(_lcd_clear); lcd_out(1,1,"7 : To main"); Lcd_out(2,1,"Clockwise"); while(1){ PORTC.F0 = 1; delay_ms(50); PORTC.F0 = 0; PORTC.F1 = 1; delay_ms(50); PORTC.F1 = 0; PORTC.F2 = 1; delay_ms(50); PORTC.F2 = 0; PORTC.F3 = 1; DELAY_MS(50); PORTC.F3 = 0; portb=0xf1; if(portb.f4==1) { //Lcd_Out(1,6,"7"); goto m; } } } if(portb.f5==1) { Lcd_cmd(_lcd_clear); lcd_out(1,1,"7 : To main"); Lcd_Out(2,1,"AntiClockwise"); while(1){ PORTC.F3 = 1;
  • 22. Assignment No 2 Microcontroller Page | 21 delay_ms(50); PORTC.F3 = 0; PORTC.F2 = 1; delay_ms(50); PORTC.F2 = 0; PORTC.F1 = 1; delay_ms(50); PORTC.F1 = 0; PORTC.F0 = 1; DELAY_MS(50); PORTC.F0 = 0; portb=0xf1; if(portb.f4==1) { //Lcd_Out(1,6,"7"); goto m; }} } } } Q22 Design a interface of stepper motor with microcontroller Degree of circular motion is Entered from keypad and displayed on LCD