You are on page 1of 3

Introduction to Embedded Systems

Practical #3
Mohammad
Name Hasan Javed Division C
Shaikh
Class S.Y.B.Sc.IT Roll Number 21302C0035
Practical 3 Waveform Generation
Date: 16-12-22
Write a code to generate a square wave on port of microcontroller.

CODE:
#include<reg52.h>
void delay (unsigned int y)
{
unsigned int i;
for(i=0;i<y;i++)
{}
}
void main()
{
while(1)
{
P1=0x00;
delay (1000);
P1=0xFF;
delay (1000);
}
}

Output: Paste the Screenshot / Picture of the Output.

Vidyalankar School of Information Technology


Write a code to generate a triangular wave on port of microcontroller.

CODE:

#include<reg51.h>
void main()
{
int j;
while(1)
{
for(j=0;j<256;j++)
{
P0=j;
}
for(j=255;j>0;j=j-2)
{
P0=j;
}
}
}

Output: Paste the Screenshot / Picture of the Output of the Circuit

Write a code to generate a sine wave on port 1 of microcontroller.

CODE:

#include<reg51.h>
int main()
{
int j;
int
c[37]={128,150,172,192,210,226,239,248,254,255,254,248,239,226,210,192,172,150,128,106,84,6
4,46,30,17,8,2,0,2,8,17,30,46,64,84,106,128};

Vidyalankar School of Information Technology


while(1)
{
for(j=0;j<36;j++)
{
P1=c[j];
}
P1=128;
}
}

Output: Paste the Screenshot / Picture of the Output of the Circuit

Vidyalankar School of Information Technology

You might also like