打印

FT61F011A点击+随机数02

[复制链接]
116|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
34af9uc|  楼主 | 2023-9-21 21:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/***************FT61F011A点击+随机数***************/
/***************ID:共同学习stm8**QQ774145445*******/
/***************汉语拼音PinYin*********************/
/****************IDE3.10***************************/
//v0.10 框架
//v0.11 初始化
//v0.12 功能
//             FT60F011A
//         _________   _________
//        |1 VDD    \_/    VSS 8|
//    k1- |2 PA2           PA4 7|-q1
//        |3 PA1 dat       PA5 6|-q2
//只能输入|4_PA3_______clk_PA0_5|-q3
#include        "SYSCFG.h"
#define                q1                PA4
#define                q2                PA5
#define                q3                PA0
#define                k1                PA2

/**************************************************/
//void interrupt ISR(void)
void        chushihua();                //初始化
void        yanshi_100ms();                //延时100ms
void        yanshi_10ms();                //延时10ms
/**************************************************/
const unsigned char biao[]={
1,5,3,7,8,
2,3,5,8,4,
6,2,7,3,6,
8,4,3,7,2,
5,6,2,7,3};
/**************************************************/
main()
{
unsigned char a1;
unsigned char b1,b2;
unsigned char c1,c2;                //c1秒
chushihua();

for(a1=30;a1>0;a1--)        {yanshi_100ms();}                //延时3秒       
q1                =1;  
for(a1=3;a1>0;a1--)                {yanshi_100ms();}
q1                =0;
for(a1=5;a1>0;a1--)                {yanshi_100ms();}
while(1)
{
for(b1=0;b1<24;b1++)
        {
    for(c1=0;c1<10;c1++)                //秒
                {
        for(c2=0;c2<80;c2++) {yanshi_10ms();}                //阻塞800ms
        q2                =1;                //每秒执行一次
        yanshi_100ms();
        q2                =0;
        yanshi_100ms();

        b2                =biao[b1];
        if(b2 ==c1)                //0-9随机执行一次
                        {
                        q3                =1;
                        yanshi_100ms();
                        q3                =0;
                        yanshi_100ms();        
                        }
                }


        }
}

}
/**************************************************/
void        chushihua()                //初始化
{
//输出配置
q1                        =0;
q2                        =0;
q3                        =0;
TRISA4                =0;                //1输入0输出
TRISA5                =0;
TRISA0                =0;

//输入配置
TRISA2                =1;                //1输入
nPAPU                =0;                //上拉由各端口锁存器值使能
WPUA2                =1;                //开上拉电阻

}
/**************************************************/
void        yanshi_100ms()                //延时100ms
{
unsigned char x1,x2;
for(x1=100;x1>0;x1--)
        {for(x2=220;x2>0;x2--);}
}
/**************************************************/
void        yanshi_10ms()                //延时10ms
{
unsigned char y1,y2;
for(y1=2;y1>0;y1--)
        {for(y2=120;y2>0;y2--);}
}

/**************************************************/
/**************************************************/
/**************************************************
void interrupt ISR(void)
{
}
/**************************************************/

1235.zip

1.54 KB

使用特权

评论回复

相关帖子

发新帖
您需要登录后才可以回帖 登录 | 注册

本版积分规则

284

主题

441

帖子

55

粉丝