Embed Lab 1 To 4
Embed Lab 1 To 4
TECHNOLOGY”
#include<stdio.h>
#include<at89x51.h>
void main()
{
SCON=0x50;
TMOD=0x20;
TH1=221;
TR1=1;
TI=1;
while(1)
{
printf("SONA COLLEGE OF TECHNOLOGY,\n");
}
}
Program to display the character “Sona ECE Embedded
Lab”
#include<stdio.h>
#include<at89x51.h>
void main()
{
SCON=0x50;
TMOD=0x20;
TH1=221;
TR1=1;
TI=1;
while(1)
{
printf("SONA ECE EMBEDDED LAB,\n");
}
}
Program to glow alternate LED’s
#include<stdio.h>
#include<at89x51.h>
void main()
{
while(1)
{
P0=0XAA; // ALTERNATE ON
P1= 0X55;
}
}
Program to glow LSB LED’s
#include<stdio.h>
#include<at89x51.h>
void main()
{
while(1)
{
P0=0x0F;
}
}
Program to turn on and turn off the LED’S with time
delay
#include<stdio.h>
#include<at89x51.h>
void delay();
int i;
void delay()
{
for(i=0;i<10000;i++);
}
void main()
{
while(1)
{
P0=0xAA;
delay();
P0=0x00;
delay();
}
}
Program to turn on and turn off LSB and MSB
alternatively
#include<stdio.h>
#include<at89x51.h>
void delay();
int i;
void delay()
{
for(i=0;i<10000;i++);
}
void main()
{
while(1)
{
P0=0x0F;
delay();
P0=0xF0;
delay();
}
}
Program to
Switch 1 on - All the LED’s have to glow
Switch 2 on – Alternate LED’s have to glow
#include<stdio.h>
#include<at89X51.h>
void main()
{
while(1)
{
if(P0_0=='1')
{
P1=0xFF; //switch 1
}
else if(P0_1=='1')
{ //switch2
P1=0xAA;
}
else {
P1=0x00;
}}
switch 1on- all on switch 1 off- alternatively on WITH
TIME DELAY
#include<stdio.h>
#include<at89X51.h>
void delay();
int i;
void delay(){
for(i=0;i<=10000;i++);
//delay
}
void main()
{
while(1)
{
if(P0_0=='1')
{
//SWITCH ON
delay();
P1=0xFF;
delay();
P1=0x00;
}
else {
delay(); //SWITCH OFF
P1=0xAA;
delay();
P1=0x00;
}
}
Switch 1 on – embedded lab
Switch 2 on – switch 2 is pressed
#include<stdio.h>
#include<at89X51.h>
void delay();
int i;
void main()
{
SCON =0x50;
TMOD=0x20;
TH1=221;
TR1=1;
TI=1;
while(1)
{
if(P0==0x01)
{
//SWITCH 1
printf("EMBEDDED LAB\n");
P3=0x22;
}
}
else{
P1=0x00;
}
}
}
void delay(){
for(i=0;i<=10000;i++);
//delay
}