SlideShare a Scribd company logo
Interface 7 Segment with MC. Display the number from 0-9 on 7 Segment
CODING
#define LED PORTC
int j=0;
int i=0;
void main()
{
unsigned char LD[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
TRISC=0;
LED=0;
while(1)
{
for(i=0;i<10;i++)
{
LED=LD[i];
delay_ms(200);
}
}
}
input byte of data in MC at Rb0 serially one bit at a time. LSB should come first
CODING
#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;
}
Input byte of data in MC at Rb0 serially one bit at a time. MSB should come first
CODING
#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;
}
Controlling direction of Stepper Motor
CODING
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;
}
ON OFF AC BULB 220V USING RELAY N MC
HARDWARE
CODING
void main()
{
TRISD.F0=0;
TRISB.F0=1;
portd.f0=0;
while(1)
{
if(PORTB.F0==1)
{
portd.f0=1;
delay_ms(200);
}
portd.f0=0;
}
}
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
CODING
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 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 = ' ';
char keypadPort at PORTB;
void step(unsigned char);
void step(unsigned char st)
{
portc=st;
}
void main(){
unsigned int temp;
unsigned int key;
unsigned char i,n;
TRISD=0;
Keypad_Init();
Lcd_Init();
Lcd_Config(&PORTD,3,1,2,0,7,6,5,4);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1, "LCD ON ");
Delay_ms(500);
do {
temp = Keypad_key_click();
delay_ms(500);
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);
}
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);
}

More Related Content

DOC
Microcontroller Programming Assignment
PDF
ADC (Analog to Digital conversion) using LPC 1768
PDF
Program LCD ARM
PDF
1.arm tutorial(gpio)
DOCX
22 Microcontroller Programs
PDF
Micro
PDF
برمجة الأردوينو - اليوم الثاني
TXT
Atmega lcd programing_with_header_file
Microcontroller Programming Assignment
ADC (Analog to Digital conversion) using LPC 1768
Program LCD ARM
1.arm tutorial(gpio)
22 Microcontroller Programs
Micro
برمجة الأردوينو - اليوم الثاني
Atmega lcd programing_with_header_file

What's hot (20)

TXT
Two digit-countdown-timer
PPTX
Seven Segment Displau
DOCX
Micro Assignment 1
PDF
LED Blinking logic on LPC1768
PDF
Assignment#4a
PDF
Assignment#5
PDF
Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
PDF
Assignment#6
PDF
Assignment#4b
PDF
Assignment#2
PDF
Compteur ARDUINO
PDF
Arduino based applications part 1
DOCX
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
PDF
Assignment#3a
PDF
Assignment#7b
PPTX
DOCX
Solution doc
PPTX
PDF
Verilog VHDL code Decoder and Encoder
Two digit-countdown-timer
Seven Segment Displau
Micro Assignment 1
LED Blinking logic on LPC1768
Assignment#4a
Assignment#5
Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
Assignment#6
Assignment#4b
Assignment#2
Compteur ARDUINO
Arduino based applications part 1
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
Assignment#3a
Assignment#7b
Solution doc
Verilog VHDL code Decoder and Encoder
Ad

Similar to 22 microcontroller programs (20)

PPTX
Applications of microcontroller(8051)
PPTX
Motordrive
PPT
Topviewsimulator
PDF
Howto Design a Stepper Motor System Using an 8-bit Freescale microcontroller ...
PDF
Stepper motor controller using c
PDF
PWM wave generator using microcontroller
PDF
Pwm wave
DOCX
codings related to avr micro controller
PDF
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
PDF
Simulation Design of DC Motor Control System Based on MC9S12D64 MCU
PPT
microcontroller pwm stepper moter prog 2.ppt
PDF
PDF
Lecture mp 7(interface)
PDF
Combine the keypad and LCD codes in compliance to the following requ.pdf
PPTX
ee2004Assignment_four_SemB24-25kk25.pptx
PDF
OpenBot-Code
PDF
Musical Machines and Flapping Phones
PDF
Open bot
TXT
PIC and LCD
Applications of microcontroller(8051)
Motordrive
Topviewsimulator
Howto Design a Stepper Motor System Using an 8-bit Freescale microcontroller ...
Stepper motor controller using c
PWM wave generator using microcontroller
Pwm wave
codings related to avr micro controller
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
Simulation Design of DC Motor Control System Based on MC9S12D64 MCU
microcontroller pwm stepper moter prog 2.ppt
Lecture mp 7(interface)
Combine the keypad and LCD codes in compliance to the following requ.pdf
ee2004Assignment_four_SemB24-25kk25.pptx
OpenBot-Code
Musical Machines and Flapping Phones
Open bot
PIC and LCD
Ad

More from babak danyal (20)

DOCX
applist
PPT
Easy Steps to implement UDP Server and Client Sockets
PPT
Java IO Package and Streams
PPT
Swing and Graphical User Interface in Java
PPT
Tcp sockets
PPTX
block ciphers and the des
PPT
key distribution in network security
PPT
Lecture10 Signal and Systems
PPT
Lecture8 Signal and Systems
PPT
Lecture7 Signal and Systems
PPT
Lecture6 Signal and Systems
PPT
Lecture5 Signal and Systems
PPT
Lecture4 Signal and Systems
PPT
Lecture3 Signal and Systems
PPT
Lecture2 Signal and Systems
PPT
Lecture1 Intro To Signa
PPT
Lecture9 Signal and Systems
PPT
Lecture9
PPT
Cns 13f-lec03- Classical Encryption Techniques
PPT
Classical Encryption Techniques in Network Security
applist
Easy Steps to implement UDP Server and Client Sockets
Java IO Package and Streams
Swing and Graphical User Interface in Java
Tcp sockets
block ciphers and the des
key distribution in network security
Lecture10 Signal and Systems
Lecture8 Signal and Systems
Lecture7 Signal and Systems
Lecture6 Signal and Systems
Lecture5 Signal and Systems
Lecture4 Signal and Systems
Lecture3 Signal and Systems
Lecture2 Signal and Systems
Lecture1 Intro To Signa
Lecture9 Signal and Systems
Lecture9
Cns 13f-lec03- Classical Encryption Techniques
Classical Encryption Techniques in Network Security

Recently uploaded (20)

PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Lesson notes of climatology university.
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Complications of Minimal Access Surgery at WLH
PPTX
master seminar digital applications in india
PDF
Classroom Observation Tools for Teachers
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Trump Administration's workforce development strategy
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Supply Chain Operations Speaking Notes -ICLT Program
Lesson notes of climatology university.
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Complications of Minimal Access Surgery at WLH
master seminar digital applications in india
Classroom Observation Tools for Teachers
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial diseases, their pathogenesis and prophylaxis
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Trump Administration's workforce development strategy
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Cell Types and Its function , kingdom of life
O5-L3 Freight Transport Ops (International) V1.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx

22 microcontroller programs

  • 1. Interface 7 Segment with MC. Display the number from 0-9 on 7 Segment CODING #define LED PORTC int j=0; int i=0; void main() { unsigned char LD[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; TRISC=0; LED=0; while(1) { for(i=0;i<10;i++) { LED=LD[i]; delay_ms(200); } } } input byte of data in MC at Rb0 serially one bit at a time. LSB should come first CODING #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; }
  • 2. Input byte of data in MC at Rb0 serially one bit at a time. MSB should come first CODING #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; } Controlling direction of Stepper Motor CODING 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; } ON OFF AC BULB 220V USING RELAY N MC
  • 4. 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 CODING 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; }}
  • 5. 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 = ' '; char keypadPort at PORTB; void step(unsigned char); void step(unsigned char st) { portc=st; } void main(){ unsigned int temp; unsigned int key; unsigned char i,n; TRISD=0; Keypad_Init(); Lcd_Init(); Lcd_Config(&PORTD,3,1,2,0,7,6,5,4); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1, 1, "LCD ON "); Delay_ms(500); do { temp = Keypad_key_click(); delay_ms(500); 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;
  • 6. 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); }
  • 7. 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); }