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
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1. ON OFF LED through a switch?2. ON OFF LED Sequentially with PORTB3. 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 furnace20. 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
Page | 1
Assignment No 2 Microcontroller
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;} }}
Page | 2
Assignment No 2 Microcontroller
Q .2 Write a program to ON OFF LED Sequentially with PORTB.
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;
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;}
}
Page | 5
Assignment No 2 Microcontroller
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;}
}
Page | 6
Assignment No 2 Microcontroller
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; } }
Page | 7
Assignment No 2 Microcontroller
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) {
}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
Page | 8
Assignment No 2 Microcontroller
I++;}I=0;Unsigned char temp;While(i!=8){
Temp=Bitdata;Temp=Temp<<1;Bitdata=Bitdata>>1;
}}Q 11 write 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;
}}
Page | 9
Assignment No 2 Microcontroller
Q 12 writes a program to control the direction of DCMOTOR portC through a switch on Portb?
} }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 directionsbit LCD_RS_Direction at TRISD3_bit;sbit LCD_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;
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 directionsbit LCD_RS_Direction at TRISD3_bit;sbit LCD_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;
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 directionsbit LCD_RS_Direction at TRISD3_bit;sbit LCD_EN_Direction at TRISD2_bit;
Page | 18
Assignment No 2 Microcontroller
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;
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 > Anticlockwise2> Clockwisesbit 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 directionsbit LCD_RS_Direction at TRISD3_bit;sbit LCD_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();