51單片機電子琴C代碼
#include
#include
#include
#include
#define uchar unsigned char
typedef unsigned char uint8; // 無符號8位整型變量
typedef signed char int8; // 有符號8位整型變量
typedef unsigned short uint16; // 無符號16位整型變量
typedef signed short int16; // 有符號16位整型變量
typedef unsigned int uint32; // 無符號32位整型變量
typedef signed int int32; // 有符號32位整型變量
typedef float fp32; // 單精度浮點數(shù)(32位長度)
typedef double fp64; // 雙精度浮點數(shù)(64位長度)
sbit row1 = P1 ^ 0;
sbit row2 = P1 ^ 1;
sbit row3 = P1 ^ 2;
sbit col1 = P0 ^ 1;
sbit col2 = P0 ^ 2;
sbit col3 = P0 ^ 3;
sbit col4 = P0 ^ 4;
sbit col5 = P0 ^ 5;
sbit col6 = P0 ^ 6;
sbit col7 = P0 ^ 7;
#define uint unsigned int
uchar STH0; //定時器計數(shù)初值
uchar STL0;
bit FY=0; //放樂曲時FY=1, 電子琴彈奏時FY=0
uchar Song_Index=0,Tone_Index=0; //放音樂的參數(shù)
uchar k, key;
sbit SPK=P3^7;
sbit LED1=P1^0;
sbit LED2=P1^1;
sbit LED3=P3^4;
sbit LED4=P3^5;
sbit LED5=P3^6;
void Delay(uint16 count)
{
}
uint8 KeyDown(void)
{
}
uint8 KeyUp(void)
{
}
uint8 KeyNum(void)
{
col1=1; col2=1; col3=1; col4=0; col5=1; col6=1; col7=1;
col1=1; col2=1; col3=1; col4=1; col5=0; col6=1; col7=1;
col1=1; col2=1; col3=1; col4=1; col5=1; col6=0; col7=1;
col1=1; col2=1; col3=1; col4=1; col5=1; col6=1; col7=0;
}
關鍵詞:
51單片機電子琴C代
評論