#include<math.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
main(){
int driver, mode;
int x,y,hz,vm;
int mx,my,xmax, ymax;
double sinA, angle;
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\tc\\bgi");
// driver = DETECT;
// initgraph(&driver, &mode,"d:\\tcc\\bgi");
//*****************************
//** FOR HORIZONTAL AND VERTICAL LINE**//
setcolor(3);
xmax = getmaxx();
ymax = getmaxy();
for(mx=0;mx<=640;mx=mx+40)
line(mx,0, mx, ymax);
for(my=0;my<=479;my=my+40)
line(0,my, xmax, my);
setcolor(15);
line(xmax/2,0, xmax/2, ymax);
line(0,ymax/2, xmax, ymax/2);
setcolor(12);
rectangle(0,0,xmax,ymax);
setfillstyle(1,0);
bar(1,1,79,39);
printf("Hz(max-5Hz) = ");
scanf("%d",&hz);
printf("Volt(max-6) = ");
scanf("%d",&vm);
setfillstyle(1,0);
bar(201,441,439,479);
moveto(218,449);
setcolor(15);
settextstyle(2,0,6);
outtext("SHEIKH.CSE-00315306015");
//***********************
setfillstyle(1,0);
bar(521,1,639,79);
//************************
setcolor(12);
rectangle(0,0,xmax,ymax);
//************************
//** For Wave making**//
for(x=0;x<xmax;++x)
{
delay(5);
angle=((double)x/xmax)*hz*2*22/7;
sinA=sin(angle);
y=240-vm*40*sinA;
putpixel(x,y,12);
moveto(530,5);
settextstyle(2,0,4);
setcolor(12);
outtext("RED = sin0ø");
}
// wave 2=============================
for(x=0;x<xmax;++x)
{
delay(5);
angle=((double)x/xmax)*hz*2*22/7;
sinA=sin(angle+120);
y=240-vm*40*sinA;
putpixel(x,y,14);
moveto(530,25);
settextstyle(2,0,4);
setcolor(14);
outtext("YELLOW = sin120ø");
}
// wave 3 ================================
for(x=0;x<xmax;++x)
{
delay(5);
angle=((double)x/xmax)*hz*2*22/7;
sinA=sin(angle+240);
y=240-vm*40*sinA;
putpixel(x,y,9);
moveto(530,45);
settextstyle(2,0,4);
setcolor(9);
outtext("BLUE = sin240ø");
}
getch();
closegraph();
}
DESCRIPTION:
Oscilloscope
Uses 5
header file in this program
#include<graphics.h> use because
this program write in graphics mode.
#include<conio.h> use for
compiler terbo c.
#include <dos.h> use for
delay() function.
This
part uses for initialize graphic mode
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\tc\\bgi");
……………………………………………………………….
Variables
Declaration:
int driver, mode;
int x,y,hz,vm;
int mx,my,xmax, ymax;
double sinA, angle;
……………………………………………………………….
Consol
drawing:
setcolor(3);
xmax = getmaxx();
ymax = getmaxy();
for(mx=0;mx<=640;mx=mx+40)
line(mx,0, mx, ymax);
for(my=0;my<=479;my=my+40)
line(0,my, xmax, my);
setcolor(15);
line(xmax/2,0, xmax/2, ymax);
line(0,ymax/2, xmax, ymax/2);
setcolor(12);
rectangle(0,0,xmax,ymax);
……………………………………………………………….
User
Data Input:
setfillstyle(1,0);
bar(1,1,79,39);
printf("Hz(max-5Hz) = ");
scanf("%d",&hz);
printf("Volt(max-6) = ");
scanf("%d",&vm);
……………………………………………………………….
Programmer
information, in graphics text
……………………………………………………………….
setfillstyle(1,0);
bar(201,441,439,479);
moveto(218,449);
setcolor(15);
settextstyle(2,0,6);
outtext("SHEIKH.CSE-00315306015");
Wave
shape making:
for(x=0;x<xmax;++x)
{
delay(5);
angle=((double)x/xmax)*hz*2*22/7;
sinA=sin(angle);
y=240-vm*40*sinA;
putpixel(x,y,12);
moveto(530,5);
settextstyle(2,0,4);
setcolor(12);
outtext("RED = sin0ø");
……………………………………………………………….
Display
latch instill user pressing any key
And than close Graph
Getch();
Closegraph();
THANK YOU
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\tc\\bgi");
int x,y,hz,vm;
int mx,my,xmax, ymax;
double sinA, angle;
xmax = getmaxx();
ymax = getmaxy();
for(mx=0;mx<=640;mx=mx+40)
line(mx,0, mx, ymax);
for(my=0;my<=479;my=my+40)
line(0,my, xmax, my);
setcolor(15);
line(xmax/2,0, xmax/2, ymax);
line(0,ymax/2, xmax, ymax/2);
setcolor(12);
rectangle(0,0,xmax,ymax);
bar(1,1,79,39);
printf("Hz(max-5Hz) = ");
scanf("%d",&hz);
printf("Volt(max-6) = ");
scanf("%d",&vm);
bar(201,441,439,479);
moveto(218,449);
setcolor(15);
settextstyle(2,0,6);
outtext("SHEIKH.CSE-00315306015");
{
delay(5);
angle=((double)x/xmax)*hz*2*22/7;
sinA=sin(angle);
y=240-vm*40*sinA;
putpixel(x,y,12);
moveto(530,5);
settextstyle(2,0,4);
setcolor(12);
outtext("RED = sin0ø");
No comments:
Post a Comment