摘要:写作用。定义绿灯的引脚,定义数据类型的key引脚,定义输出,定义key为输入,设置为高电平。循环它以保持程序运行。
用AB32VG1在RT-Thread Studio中写。
# include # include " board . h " int main(void){ uint 8 _ t green = rt _ pin _ get(" PE . 4 ");//定义绿色LED灯的管脚,uint8_t为数据类型uint 8 _ t key = rt _ pin _ get(" pf . 1 ");//定义key引脚RT _ pin _ mode(绿色,pin _ mode _ output);//定义LED为输出rt _ pin _ mode (key,pin _ mode _ input _ pull up);//定义按键进入rt_pin_write(绿色,PIN _ HIGH);//将LED设置为高电平同时(1){ if(RT _ pin _ read(key)= = 1){ RT _ pin _ write(green,pin _ low);} if(rt _ PIN _ read(key)= = 0){ rt _ PIN _ write(绿色,PIN _ HIGH);}//while循环应该存在以保持程序运行}}
评论前必须登录!
注册