SlideShare ist ein Scribd-Unternehmen logo
1 von 8
Program to toggle the LED
#include<reg51.h>
Void delay (void);
Unsigned int i;
Void main()
{
While(1)
{
P2=0x30;
delay();
P2=0x00;
delay();
}
}
void delay(void)
{
for(i=0;i<25000;i++);
}
Program to control direction and speed of a
stepper motor.
#include<reg51.h>
Static bit Dir=0;
//sbit buzzer = P0^5;
Void ChangeDir(void) interrupt 0
{
Dir = ~Dir;
}
Void delay(unsigned int x)
{
for(;x>0;x--);
}
Main{}
{
Unsigned char Val,i;
EA=0x1;
EX0=0x1;
ES=1;
While(1)
{
If(Dir)
{
Val = 0x08;
For(i=0;i<4;i++)
{
P0 = Val;
Val = Val>>1;
Delay(575);
}
}
Else
{
Val = 0x01;
For(i=0;i<4;i++)
{
P0 = Val;
Val = Val<<1;
Delay(575);
}
}
}
}
Program to generate square wave
#include<reg51.h>
Void delay(void);
Void main{}
{
While(1)
{
P0=0x00;
Delay();
P0=0xff;
Delay();
}
}
Void delay(void)
{
int i;
For(i=0;i<=300;i++);
}
Program to control traffic lights
#include<reg51.h>
Void delay(void);
Unsigned int i;
Void main{}
{
While(1)
{
P0=0x58;
P1=0x09;
Delay();
Delay();
Delay();
P0=0x05;
P1=0x0f;
Delay();
Delay();
Delay();
P0=0x54;
P1=0x06;
Delay();
Delay();
P0=0xd0;
P1=0x07;
Delay();
Delay();
Delay();
P0=0x92;
P1=0x05;
Delay();
Delay();
P0=0xf0;
P1=0x05;
Delay();
Delay();
P0=0x61;
P1=0x05;
Delay();
Delay();
P0=0x70;
P1=0x0d;
Delay();
Delay();
}
}
Void delay(void)
{
For(i=0;i<35000;i++);
For(i=0;i<35000;i++);
}
Program to generate Rectangular wave
#include<reg51.h>
Void msdelay(unsigned int);
Void main{}
{
P0=00;
While(1)
{
Msdelay(50);
P0=0xff;
Msdelay(100);
P0=0x00;
}
}
Void msdelay(unsigned int value)
{
Unsigned int y;
For(y=0;y<value;y++);
}
Program to generate Triangular wave
#include<reg51.h>
idata unsigned char count;
Void main()
{
While(1)
{
For(count=0;count!=0xff;count++)
{
P0=count;
}
For(count=0xff;count>0;count--)
{
P0=count;
}
}
}

Weitere ähnliche Inhalte

Ähnlich wie Program interfacing lab

Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018UVCE
 
ADC (Analog to Digital conversion) using LPC 1768
ADC (Analog to Digital conversion) using LPC 1768ADC (Analog to Digital conversion) using LPC 1768
ADC (Analog to Digital conversion) using LPC 1768Omkar Rane
 
COA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfCOA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfJavedAnsari236392
 
HKG15-405: Redundant zero/sign-extension elimination in GCC
HKG15-405: Redundant zero/sign-extension elimination in GCCHKG15-405: Redundant zero/sign-extension elimination in GCC
HKG15-405: Redundant zero/sign-extension elimination in GCCLinaro
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IOT Academy
 
Vechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor pptVechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor pptsatish 486
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better codeDror Helper
 
Operating system and embedded systems
Operating system and embedded systemsOperating system and embedded systems
Operating system and embedded systemsgayatrigayu1
 
8051 C Assignments with all examples covered
8051 C Assignments with all examples covered8051 C Assignments with all examples covered
8051 C Assignments with all examples coveredAbdulMunaf52
 
Arithmetic and logic operations in c
Arithmetic and logic operations in cArithmetic and logic operations in c
Arithmetic and logic operations in cVikas Dongre
 
PWM wave generator using microcontroller
 PWM wave generator using microcontroller  PWM wave generator using microcontroller
PWM wave generator using microcontroller Swapnil2515
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in cAbdelrahman Elewah
 
Two digit-countdown-timer
Two digit-countdown-timerTwo digit-countdown-timer
Two digit-countdown-timerHEATLBJ
 
Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfapexelectronices01
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Svet Ivantchev
 

Ähnlich wie Program interfacing lab (19)

Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
 
ADC (Analog to Digital conversion) using LPC 1768
ADC (Analog to Digital conversion) using LPC 1768ADC (Analog to Digital conversion) using LPC 1768
ADC (Analog to Digital conversion) using LPC 1768
 
COA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfCOA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdf
 
Direct analog
Direct analogDirect analog
Direct analog
 
HKG15-405: Redundant zero/sign-extension elimination in GCC
HKG15-405: Redundant zero/sign-extension elimination in GCCHKG15-405: Redundant zero/sign-extension elimination in GCC
HKG15-405: Redundant zero/sign-extension elimination in GCC
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
 
Vechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor pptVechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor ppt
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
Operating system and embedded systems
Operating system and embedded systemsOperating system and embedded systems
Operating system and embedded systems
 
8051 C Assignments with all examples covered
8051 C Assignments with all examples covered8051 C Assignments with all examples covered
8051 C Assignments with all examples covered
 
Tools.cpp
Tools.cppTools.cpp
Tools.cpp
 
Arithmetic and logic operations in c
Arithmetic and logic operations in cArithmetic and logic operations in c
Arithmetic and logic operations in c
 
PWM wave generator using microcontroller
 PWM wave generator using microcontroller  PWM wave generator using microcontroller
PWM wave generator using microcontroller
 
Pwm wave
Pwm wave Pwm wave
Pwm wave
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in c
 
Two digit-countdown-timer
Two digit-countdown-timerTwo digit-countdown-timer
Two digit-countdown-timer
 
Flex sensor
Flex sensorFlex sensor
Flex sensor
 
Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdf
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
 

Kürzlich hochgeladen

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
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
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
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 

Kürzlich hochgeladen (20)

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
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
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)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.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
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

Program interfacing lab

  • 1. Program to toggle the LED #include<reg51.h> Void delay (void); Unsigned int i; Void main() { While(1) { P2=0x30; delay(); P2=0x00; delay(); } } void delay(void) { for(i=0;i<25000;i++); }
  • 2. Program to control direction and speed of a stepper motor. #include<reg51.h> Static bit Dir=0; //sbit buzzer = P0^5; Void ChangeDir(void) interrupt 0 { Dir = ~Dir; } Void delay(unsigned int x) { for(;x>0;x--); } Main{} { Unsigned char Val,i; EA=0x1; EX0=0x1; ES=1; While(1) { If(Dir) { Val = 0x08; For(i=0;i<4;i++) { P0 = Val; Val = Val>>1; Delay(575); } } Else {
  • 3. Val = 0x01; For(i=0;i<4;i++) { P0 = Val; Val = Val<<1; Delay(575); } } } }
  • 4. Program to generate square wave #include<reg51.h> Void delay(void); Void main{} { While(1) { P0=0x00; Delay(); P0=0xff; Delay(); } } Void delay(void) { int i; For(i=0;i<=300;i++); }
  • 5. Program to control traffic lights #include<reg51.h> Void delay(void); Unsigned int i; Void main{} { While(1) { P0=0x58; P1=0x09; Delay(); Delay(); Delay(); P0=0x05; P1=0x0f; Delay(); Delay(); Delay(); P0=0x54; P1=0x06; Delay(); Delay(); P0=0xd0; P1=0x07; Delay(); Delay(); Delay(); P0=0x92; P1=0x05; Delay(); Delay(); P0=0xf0; P1=0x05; Delay(); Delay(); P0=0x61; P1=0x05; Delay(); Delay(); P0=0x70; P1=0x0d;
  • 7. Program to generate Rectangular wave #include<reg51.h> Void msdelay(unsigned int); Void main{} { P0=00; While(1) { Msdelay(50); P0=0xff; Msdelay(100); P0=0x00; } } Void msdelay(unsigned int value) { Unsigned int y; For(y=0;y<value;y++); }
  • 8. Program to generate Triangular wave #include<reg51.h> idata unsigned char count; Void main() { While(1) { For(count=0;count!=0xff;count++) { P0=count; } For(count=0xff;count>0;count--) { P0=count; } } }