SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Program 1: Write program to on off LED with some delay. LED is connected to port Rb0
#define LED PORTB.F0
void main()
{
TRISB.F0=0;
LED=0;
while(1)
{
LED=1;
delay_ms(1000);
LED=0;
delay_ms(1000);
}
}
Design:
Program 2: Interface 7 Segment with MC. Display the number from 0-9 on 7 Segment
#define LED PORTC
int j=0,i=0;
void main()
{
unsigned char arr[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
TRISC=0;
LED=0;
while(1)
{
for(i=0;i<10;i++)
{
LED=arr[i];
delay_ms(100);
}
}
}
Design:
Program 3: Write a program to count numbers from 00 to FF on PORT B
#define LED PORTB
unsigned char i=0x00;
void main(void)
{
TRISB=0;
LED=OFF;
while(i<0xFF)
{
LED=1;
Delay_ms(100);
LED=0;
Delay_ms(100);
i++;
}
}
Design:
Program 4: Write Program to read data on PORT B and send it on PORT C
#define a PORTB
#define b PORTC
void main()
{
TRISC=0X00;
TRISB=0XFF;
while(1)
{
b=a;
}
}
Design:
Program 5: Write Program to read data on PORT B and send it on PORT C in inverted form
#define a PORTB
#define b PORTC
void main()
{
TRISC=0X00;
TRISB=0XFF;
while(1)
{
b=~a;
}
}
Design:
Program 6: Write a program to input byte of data in MC at Rb0 serially one bit at a time. LSB
should come first
#define pb0 portb.f0
void main()
{
unsigned char x;
unsigned char assign=0;
trisb.f0=1;
trisd=0;
for(x=0;x<8;x++)
{
assign=assign>>1;
assign=(pb0 & 0x01)<<7;
}
portd=assign;
}
Design:
Program 7: Write a program to input byte of data in MC at Rb0 serially one bit at a time. MSB
should come first
#define pb0 portb.f0
void main()
{
unsigned char x;
unsigned char assign=0;
trisb.f0=1;
trisd=0;
for(x=0;x<8;x++)
{
assign=assign<<1;
assign=pb0 & 0x01;
}
portd=assign;
}
Design:
Program 8: Write a program to output byte of data in MC at Rb0 serially one bit at a time. MSB
should go first
#define LED PORTB.F0
void main()
{
unsigned char a,x;
unsigned int i;
x=0X45;
TRISB.F0=0;
LED=0;
a=x;
while(1)
{
for(i=7;i>=0;i--)
{
a=x;
LED=a>>i;
delay_ms(100);
if(i==0)
{
i=7;
a=x;
break;
}
}
}
}
Design:
Program 9: Write a program to input byte of data in MC at Rb0 serially one bit at a time. LSB
should go first
#define LED PORTB.F0
int i=0;
void main()
{
unsigned char x,a;
x=0xAA;
a=x;
TRISB.F0=0;
while(1)
{
a=a>>1;
LED=a;
delay_ms(100);
i++;
if(i==7)
{
i=0;
a=x ;
}
}
}
Design:
Program 10: Write a program to on off AC Bulb 220v using relay n MC
# define r PORTB.F0
# define s PORTB.F1
void main()
{
TRISB.F0=0;
TRISB.F1=1;
relay=0;
while(1)
{
if(s==0)
{
r=1;
}
else
{
r=0;
}
}
}
Design:
Program 11: Write a program to on off DC motor using switch. If switch is on, Motor moves
clockwise and vise versa
# define S PORTB.F0
# define C PORTC.F0
# define A PORTC.F1
void main(void)
{
TRISB.F0=1;
TRISC.F0=0;
TRISC.F1=0;
C=0;
A=0;
S=0;
while(1)
{
if(S==1)
{
C=1;
A=0;
}
else
{
C=0;
A=1;
}
}
}
Design:
Program 12: Write a program to control direction of Stepper Motor
void step(unsigned char);
void main()
{
unsigned char i;
trisd=0;
for(i=1;i<=40;i++)
{
step(0x03);
delay_ms(1000);
step(0x06);
delay_ms(1000);
step(0x0c);
delay_ms(1000);
step(0x09);
delay_ms(1000);
}
}
void step(unsigned char st)
{
portd=st;
}
Design:
Program 13: Design pressure controller using switch. Specifications of pressure switch is
given, At 100 Bar switch is Break. At 5 Bar Switch is Make.. Interface Pressure switch with MC to
perform the following tasks.
1.If switch is make, Start the Motor
2.If switch is break, Off the Motor
#define M PORTD.F0
unsigned int r=0;
void interrupt(void)
{
M=1;
if(INTCON.INT0IF==1)
{
if(r==1)
{
INTCON2.INTEDG0=1;
r=0;
}
else
{
M=1;
INTCON2.INTEDG0=0;
r=1;
}
}
}
void main()
{
TRISB.F0=1;
TRISD.F0=0;
INTCON=0x90;
INTCON2.INTEDG0=1;
M=0;
while(1){ }
}
Design:
Program 14: Write a program to display number of persons entering in building on LCD
Program 15: Design Temperature control system for furnace, Two temperature switches are
installed in furnace to sense hotness and coldness. Specification for hot sensors is Temperature
greater than 100 degree, For Cold sensors is temperature less than 35 degree. If Furnace is Hot
Make flame off, If furnace is Cold make flame on
void main(void)
{
TRISC=0;
INTCON.GIE=1;
INTCON.INT0IF=0;
INTCON.INT0IE=1;
INTCON3.INT1IF=0;
INTCON3.INT1IE=1;
INTCON2.INTEDG0=1;
INTCON2.INTEDG1=1;
while(1)
{ }
}
void interrupt (void)
{
Lcd_Init(&PORTC); // Initialize LCD connected to PORTC
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
if(INTCON.INT0IF)
{
Lcd_Out(1, 1, "FURNANCE OFF");
INTCON.INT0IF=0;
}
if(INTCON3.INT1IF)
{
Lcd_Out(1, 1, "FURNANCE ON");
INTCON3.INT1IF=0;
}
}
Design:
Program 16: Design the interface of keypad with MC & display pressed key on LCD
unsigned char kp = ' ';
unsigned int get_Kp();
char keypadPort at PORTB;
sbit LCD_RS at RD0_bit;
sbit LCD_EN at RD1_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
void main()
{
unsigned int temp;
Keypad_Init();
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1, "LCD ON ");
Delay_ms(500);
do
{
temp = get_Kp();
Lcd_Cmd(_LCD_CLEAR); // Clear display
switch (temp) {
case 1: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "/"); break; // /
case 2: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "*"); break; // *
case 3: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "-"); break; // -
case 4: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "+"); break; // +
case 5: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "9"); break; // 9
case 6: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "6"); break; // 6
case 7: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "3"); break; // 3
case 8: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "="); break; // =
case 9: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "8"); break; // 8
case 10: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "5"); break; // 5
case 11: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "2"); break; // 2
case 12: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "0"); break; // 0
case 13: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "7"); break; // 7
case 14: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "4"); break; // 4
case 15: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "1"); break; // 1
case 16: Lcd_Cmd(_LCD_CLEAR); break; // clear
}
Lcd_Out(2, 1, kp);
} while (1);
}
unsigned int get_Kp()
{
unsigned int kp1 = 0;
do{
kp1 = Keypad_Key_Click();
}while (!kp1);
return kp1;
}
Program 17: Design the interface of stepper motor with MC, Degree of circular motion of
stepper motor is entered from keypad and display degree & Motion on LCD
unsigned char kp = ' ';
unsigned int get_Kp();
char keypadPort at PORTB;
sbit LCD_RS at RD0_bit;
sbit LCD_EN at RD1_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
void step(unsigned char);
void step(unsigned char st)
{
portc=st;
}
void main(){
unsigned int temp;
unsigned int key;
unsigned char i,n;
TRISC=0;
Keypad_Init();
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1, "LCD ON ");
Delay_ms(500);
do {
temp = get_Kp();
Lcd_Cmd(_LCD_CLEAR);
switch (temp) {
case 5: Lcd_Cmd(_LCD_CLEAR); key=9; Lcd_Out(1, 1, "9"); break;
case 6: Lcd_Cmd(_LCD_CLEAR); key=6; Lcd_Out(1, 1, "6"); break;
case 7: Lcd_Cmd(_LCD_CLEAR); key=3; Lcd_Out(1, 1, "3"); break;
case 9: Lcd_Cmd(_LCD_CLEAR); key=8; Lcd_Out(1, 1, "8"); break;
case 10: Lcd_Cmd(_LCD_CLEAR); key=5; Lcd_Out(1, 1, "5"); break;
case 11: Lcd_Cmd(_LCD_CLEAR); key=2; Lcd_Out(1, 1, "2"); break;
case 12: Lcd_Cmd(_LCD_CLEAR); key=0; Lcd_Out(1, 1, "0"); break;
case 13: Lcd_Cmd(_LCD_CLEAR); key=7; Lcd_Out(1, 1, "7"); break;
case 14: Lcd_Cmd(_LCD_CLEAR); key=4; Lcd_Out(1, 1, "4"); break;
case 15: Lcd_Cmd(_LCD_CLEAR); key=1; Lcd_Out(1, 1, "1"); break;
case 16: Lcd_Cmd(_LCD_CLEAR); break;
}
trisd=0;
n=30/key;
for(i=1;i<=n;i++)
{
step(0x03);
delay_ms(300);
step(0x06);
delay_ms(300);
step(0x0c);
delay_ms(300);
step(0x09);
delay_ms(300);
}
} while (1);
}
unsigned int get_Kp(){
unsigned int kp1 = 0;
do{
kp1 = Keypad_Key_Click();
}while (!kp1);
return kp1;
}

Weitere ähnliche Inhalte

Was ist angesagt?

Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming Dr. Pankaj Zope
 
Cascade Shadow Mapping
Cascade Shadow MappingCascade Shadow Mapping
Cascade Shadow MappingSukwoo Lee
 
Flipflops JK T SR D All FlipFlop Slides
Flipflops JK T SR D All FlipFlop SlidesFlipflops JK T SR D All FlipFlop Slides
Flipflops JK T SR D All FlipFlop SlidesSid Rehmani
 
Xilinx lca and altera flex
Xilinx lca and altera flexXilinx lca and altera flex
Xilinx lca and altera flexanishgoel
 
Lqiuid Crystal: Display applications
Lqiuid Crystal: Display applicationsLqiuid Crystal: Display applications
Lqiuid Crystal: Display applicationsMonika Gupta
 
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기동석 김
 
Delays in verilog
Delays in verilogDelays in verilog
Delays in verilogJITU MISTRY
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshopatuline
 
I2C BUS
I2C BUSI2C BUS
I2C BUSp_ayal
 
Direct x 12 초기화
Direct x 12 초기화Direct x 12 초기화
Direct x 12 초기화QooJuice
 
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)포프 김
 

Was ist angesagt? (20)

Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming
 
Cascade Shadow Mapping
Cascade Shadow MappingCascade Shadow Mapping
Cascade Shadow Mapping
 
CPLD xc9500
CPLD xc9500CPLD xc9500
CPLD xc9500
 
SEQUENTIAL CIRCUITS [Flip-flops and Latches]
SEQUENTIAL CIRCUITS [Flip-flops and Latches]SEQUENTIAL CIRCUITS [Flip-flops and Latches]
SEQUENTIAL CIRCUITS [Flip-flops and Latches]
 
D flip Flop
D flip FlopD flip Flop
D flip Flop
 
Flipflops JK T SR D All FlipFlop Slides
Flipflops JK T SR D All FlipFlop SlidesFlipflops JK T SR D All FlipFlop Slides
Flipflops JK T SR D All FlipFlop Slides
 
Flip flop
Flip flopFlip flop
Flip flop
 
PIC Microcontroller | ADC Interfacing
PIC Microcontroller | ADC InterfacingPIC Microcontroller | ADC Interfacing
PIC Microcontroller | ADC Interfacing
 
Xilinx lca and altera flex
Xilinx lca and altera flexXilinx lca and altera flex
Xilinx lca and altera flex
 
Lqiuid Crystal: Display applications
Lqiuid Crystal: Display applicationsLqiuid Crystal: Display applications
Lqiuid Crystal: Display applications
 
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
 
Delays in verilog
Delays in verilogDelays in verilog
Delays in verilog
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
I2C BUS
I2C BUSI2C BUS
I2C BUS
 
Interfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 MicrocontrollerInterfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 Microcontroller
 
What is POR,LVD,WDT ?
What is POR,LVD,WDT ?What is POR,LVD,WDT ?
What is POR,LVD,WDT ?
 
Direct x 12 초기화
Direct x 12 초기화Direct x 12 초기화
Direct x 12 초기화
 
D2 Hdr
D2 HdrD2 Hdr
D2 Hdr
 
OMAP
OMAPOMAP
OMAP
 
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
 

Ähnlich wie Microcontroller Programming Assignment

22 Microcontroller Programs
22 Microcontroller Programs22 Microcontroller Programs
22 Microcontroller Programsbabak danyal
 
22 microcontroller programs
22 microcontroller programs22 microcontroller programs
22 microcontroller programsbabak danyal
 
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
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prognikhil dixit
 
Lcd interface with atmega32 avr best.ppt
Lcd interface with atmega32 avr best.pptLcd interface with atmega32 avr best.ppt
Lcd interface with atmega32 avr best.pptSoumyaGupta836456
 
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
 
Moving message display
Moving message displayMoving message display
Moving message displayviraj1989
 
Untitled 1
Untitled 1Untitled 1
Untitled 1lakachew
 
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
 

Ähnlich wie Microcontroller Programming Assignment (20)

22 Microcontroller Programs
22 Microcontroller Programs22 Microcontroller Programs
22 Microcontroller Programs
 
22 microcontroller programs
22 microcontroller programs22 microcontroller programs
22 microcontroller programs
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Program LCD ARM
Program LCD ARMProgram LCD ARM
Program LCD ARM
 
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
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prog
 
08_lcd.pdf
08_lcd.pdf08_lcd.pdf
08_lcd.pdf
 
Lcd interface with atmega32 avr best.ppt
Lcd interface with atmega32 avr best.pptLcd interface with atmega32 avr best.ppt
Lcd interface with atmega32 avr best.ppt
 
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
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
pandu-vivek (1)
pandu-vivek (1)pandu-vivek (1)
pandu-vivek (1)
 
Lcd & keypad
Lcd & keypadLcd & keypad
Lcd & keypad
 
Moving message display
Moving message displayMoving message display
Moving message display
 
_LCD display-mbed.pdf
_LCD display-mbed.pdf_LCD display-mbed.pdf
_LCD display-mbed.pdf
 
Untitled 1
Untitled 1Untitled 1
Untitled 1
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 Card
 
Direct analog
Direct analogDirect analog
Direct analog
 
ESD -DAY 24.pptx
ESD -DAY 24.pptxESD -DAY 24.pptx
ESD -DAY 24.pptx
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 

Kürzlich hochgeladen (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

Microcontroller Programming Assignment

  • 1. Program 1: Write program to on off LED with some delay. LED is connected to port Rb0 #define LED PORTB.F0 void main() { TRISB.F0=0; LED=0; while(1) { LED=1; delay_ms(1000); LED=0; delay_ms(1000); } } Design: Program 2: Interface 7 Segment with MC. Display the number from 0-9 on 7 Segment #define LED PORTC int j=0,i=0; void main() { unsigned char arr[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; TRISC=0; LED=0; while(1) { for(i=0;i<10;i++) { LED=arr[i]; delay_ms(100); } } } Design: Program 3: Write a program to count numbers from 00 to FF on PORT B #define LED PORTB unsigned char i=0x00; void main(void) { TRISB=0; LED=OFF; while(i<0xFF) { LED=1; Delay_ms(100); LED=0;
  • 2. Delay_ms(100); i++; } } Design: Program 4: Write Program to read data on PORT B and send it on PORT C #define a PORTB #define b PORTC void main() { TRISC=0X00; TRISB=0XFF; while(1) { b=a; } } Design: Program 5: Write Program to read data on PORT B and send it on PORT C in inverted form #define a PORTB #define b PORTC void main() { TRISC=0X00; TRISB=0XFF; while(1) { b=~a; } } Design: Program 6: Write a program to input byte of data in MC at Rb0 serially one bit at a time. LSB should come first #define pb0 portb.f0 void main() { unsigned char x; unsigned char assign=0; trisb.f0=1; trisd=0;
  • 3. for(x=0;x<8;x++) { assign=assign>>1; assign=(pb0 & 0x01)<<7; } portd=assign; } Design: Program 7: Write a program to input byte of data in MC at Rb0 serially one bit at a time. MSB should come first #define pb0 portb.f0 void main() { unsigned char x; unsigned char assign=0; trisb.f0=1; trisd=0; for(x=0;x<8;x++) { assign=assign<<1; assign=pb0 & 0x01; } portd=assign; } Design: Program 8: Write a program to output byte of data in MC at Rb0 serially one bit at a time. MSB should go first #define LED PORTB.F0 void main() { unsigned char a,x; unsigned int i; x=0X45; TRISB.F0=0; LED=0; a=x; while(1) { for(i=7;i>=0;i--) { a=x; LED=a>>i; delay_ms(100); if(i==0) { i=7; a=x;
  • 4. break; } } } } Design: Program 9: Write a program to input byte of data in MC at Rb0 serially one bit at a time. LSB should go first #define LED PORTB.F0 int i=0; void main() { unsigned char x,a; x=0xAA; a=x; TRISB.F0=0; while(1) { a=a>>1; LED=a; delay_ms(100); i++; if(i==7) { i=0; a=x ; } } } Design: Program 10: Write a program to on off AC Bulb 220v using relay n MC # define r PORTB.F0 # define s PORTB.F1 void main() { TRISB.F0=0; TRISB.F1=1; relay=0; while(1) { if(s==0) { r=1; } else {
  • 5. r=0; } } } Design: Program 11: Write a program to on off DC motor using switch. If switch is on, Motor moves clockwise and vise versa # define S PORTB.F0 # define C PORTC.F0 # define A PORTC.F1 void main(void) { TRISB.F0=1; TRISC.F0=0; TRISC.F1=0; C=0; A=0; S=0; while(1) { if(S==1) { C=1; A=0; } else { C=0; A=1; } } } Design: Program 12: Write a program to control direction of Stepper Motor void step(unsigned char); void main() { unsigned char i; trisd=0; for(i=1;i<=40;i++) { step(0x03); delay_ms(1000); step(0x06); delay_ms(1000); step(0x0c); delay_ms(1000);
  • 6. step(0x09); delay_ms(1000); } } void step(unsigned char st) { portd=st; } Design: Program 13: Design pressure controller using switch. Specifications of pressure switch is given, At 100 Bar switch is Break. At 5 Bar Switch is Make.. Interface Pressure switch with MC to perform the following tasks. 1.If switch is make, Start the Motor 2.If switch is break, Off the Motor #define M PORTD.F0 unsigned int r=0; void interrupt(void) { M=1; if(INTCON.INT0IF==1) { if(r==1) { INTCON2.INTEDG0=1; r=0; } else { M=1; INTCON2.INTEDG0=0; r=1; } } } void main() { TRISB.F0=1; TRISD.F0=0;
  • 7. INTCON=0x90; INTCON2.INTEDG0=1; M=0; while(1){ } } Design: Program 14: Write a program to display number of persons entering in building on LCD Program 15: Design Temperature control system for furnace, Two temperature switches are installed in furnace to sense hotness and coldness. Specification for hot sensors is Temperature greater than 100 degree, For Cold sensors is temperature less than 35 degree. If Furnace is Hot Make flame off, If furnace is Cold make flame on void main(void) { TRISC=0; INTCON.GIE=1; INTCON.INT0IF=0; INTCON.INT0IE=1; INTCON3.INT1IF=0; INTCON3.INT1IE=1; INTCON2.INTEDG0=1; INTCON2.INTEDG1=1; while(1) { } } void interrupt (void) { Lcd_Init(&PORTC); // Initialize LCD connected to PORTC Lcd_Cmd(Lcd_CLEAR); // Clear display Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off if(INTCON.INT0IF) { Lcd_Out(1, 1, "FURNANCE OFF");
  • 8. INTCON.INT0IF=0; } if(INTCON3.INT1IF) { Lcd_Out(1, 1, "FURNANCE ON"); INTCON3.INT1IF=0; } } Design: Program 16: Design the interface of keypad with MC & display pressed key on LCD unsigned char kp = ' '; unsigned int get_Kp(); char keypadPort at PORTB; sbit LCD_RS at RD0_bit; sbit LCD_EN at RD1_bit; sbit LCD_D4 at RD4_bit; sbit LCD_D5 at RD5_bit; sbit LCD_D6 at RD6_bit; sbit LCD_D7 at RD7_bit; sbit LCD_RS_Direction at TRISD0_bit; sbit LCD_EN_Direction at TRISD1_bit; sbit LCD_D4_Direction at TRISD4_bit; sbit LCD_D5_Direction at TRISD5_bit; sbit LCD_D6_Direction at TRISD6_bit; sbit LCD_D7_Direction at TRISD7_bit; void main() { unsigned int temp; Keypad_Init(); Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1, 1, "LCD ON "); Delay_ms(500);
  • 9. do { temp = get_Kp(); Lcd_Cmd(_LCD_CLEAR); // Clear display switch (temp) { case 1: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "/"); break; // / case 2: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "*"); break; // * case 3: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "-"); break; // - case 4: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "+"); break; // + case 5: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "9"); break; // 9 case 6: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "6"); break; // 6 case 7: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "3"); break; // 3 case 8: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "="); break; // = case 9: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "8"); break; // 8 case 10: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "5"); break; // 5 case 11: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "2"); break; // 2 case 12: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "0"); break; // 0 case 13: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "7"); break; // 7 case 14: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "4"); break; // 4 case 15: Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "1"); break; // 1 case 16: Lcd_Cmd(_LCD_CLEAR); break; // clear } Lcd_Out(2, 1, kp); } while (1); } unsigned int get_Kp() { unsigned int kp1 = 0; do{ kp1 = Keypad_Key_Click(); }while (!kp1); return kp1; } Program 17: Design the interface of stepper motor with MC, Degree of circular motion of stepper motor is entered from keypad and display degree & Motion on LCD
  • 10. unsigned char kp = ' '; unsigned int get_Kp(); char keypadPort at PORTB; sbit LCD_RS at RD0_bit; sbit LCD_EN at RD1_bit; sbit LCD_D4 at RD4_bit; sbit LCD_D5 at RD5_bit; sbit LCD_D6 at RD6_bit; sbit LCD_D7 at RD7_bit; sbit LCD_RS_Direction at TRISD0_bit; sbit LCD_EN_Direction at TRISD1_bit; sbit LCD_D4_Direction at TRISD4_bit; sbit LCD_D5_Direction at TRISD5_bit; sbit LCD_D6_Direction at TRISD6_bit; sbit LCD_D7_Direction at TRISD7_bit; void step(unsigned char); void step(unsigned char st) { portc=st; } void main(){ unsigned int temp; unsigned int key; unsigned char i,n; TRISC=0; Keypad_Init(); Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1, 1, "LCD ON "); Delay_ms(500); do { temp = get_Kp(); Lcd_Cmd(_LCD_CLEAR); switch (temp) {
  • 11. case 5: Lcd_Cmd(_LCD_CLEAR); key=9; Lcd_Out(1, 1, "9"); break; case 6: Lcd_Cmd(_LCD_CLEAR); key=6; Lcd_Out(1, 1, "6"); break; case 7: Lcd_Cmd(_LCD_CLEAR); key=3; Lcd_Out(1, 1, "3"); break; case 9: Lcd_Cmd(_LCD_CLEAR); key=8; Lcd_Out(1, 1, "8"); break; case 10: Lcd_Cmd(_LCD_CLEAR); key=5; Lcd_Out(1, 1, "5"); break; case 11: Lcd_Cmd(_LCD_CLEAR); key=2; Lcd_Out(1, 1, "2"); break; case 12: Lcd_Cmd(_LCD_CLEAR); key=0; Lcd_Out(1, 1, "0"); break; case 13: Lcd_Cmd(_LCD_CLEAR); key=7; Lcd_Out(1, 1, "7"); break; case 14: Lcd_Cmd(_LCD_CLEAR); key=4; Lcd_Out(1, 1, "4"); break; case 15: Lcd_Cmd(_LCD_CLEAR); key=1; Lcd_Out(1, 1, "1"); break; case 16: Lcd_Cmd(_LCD_CLEAR); break; } trisd=0; n=30/key; for(i=1;i<=n;i++) { step(0x03); delay_ms(300); step(0x06); delay_ms(300); step(0x0c); delay_ms(300); step(0x09); delay_ms(300); } } while (1); } unsigned int get_Kp(){ unsigned int kp1 = 0; do{ kp1 = Keypad_Key_Click(); }while (!kp1); return kp1; }