sine:A,fchange

/*

Chuong trinh tao song sine co bien do va tan so thay doi duoc

*/

#include "stdafx.h"

#include <conio.h>

#include <stdio.h>

#include <math.h>

#include <dos.h>

#include <PCIXP.h>

#define pi 3.141592

#define MAX 200

void delay(int time) // Tu viet ham delay.

{

int i,j;

for(i=0;i<time;i++)

for(j=0;j<1000;j++);

}

void main()

{

int add=Get_Addr("PCI_ADC");

int a[MAX];

int i,j;

char k;

printf("

Chuong trinh tao song sine co bien do va tan so thay doi duoc.");

printf("

Nhan phim 't' de tang bien do. Phim 'g' de giam bien do.");

printf("

Nhan phim 'i' de tang tan so. Phim 'd' de giam tan so.");

printf("

Nhan phim 'Esc' de thoat chuong trinh");

time = 10;

n = 1024;

do

{

while(!kbhit())

for(i=0;i<MAX;i++)

{

a[i] = 2048*sin((i*2*pi)/MAX) + n;

outportb(add+2,a[i]);

outportb(add+3,a[i]>>8);

delay(time);

}

k = getch();

if(k=='t'&& n<2000)

n = n+50;

if(k=='g'&& n>50)

n = n-50;

if(k=='d'&& time<100)

time = time+2;

if(k=='i'&& time>1)

time = time-1;

}while(k!=27);

}

}

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: #may#tinh