链接: https://pan.baidu.com/s/1WQIr13z-dVVgjUFZ5RMBtg
提取码: 5git
链接: https://pan.baidu.com/s/1WQIr13z-dVVgjUFZ5RMBtg
提取码: 5git
#include <funshield.h>
int st;
int st2;
int fd1;
int fd2;
int fd1_l;
int fd2_l;
int count;
int i_t;
int t_t;
int t_t2;
int su;
int sd;
void setup() {
pinMode(led1_pin,OUTPUT);
pinMode(led2_pin,OUTPUT);
pinMode(led3_pin,OUTPUT);
pinMode(led4_pin,OUTPUT);
pinMode(button1_pin,INPUT);
pinMode(button2_pin,INPUT);
st=0;
st2=0;
count=0;
}
void loop() {
if(digitalRead(button1_pin)){
if(st==0){
count++;
st=1;
t_t=micros();
}
if(st==1){
if(micros()-t_t>1000000){
count++;
st=2;
t_t=micros();
}
}
if(st==2){
if(micros()-t_t>300000){
count++;
t_t=micros();
}
}
}
else{
st=0;
}
if(digitalRead(button2_pin)){
if(st2==0){
count--;
st2=1;
t_t2=micros();
}
if(st2==1){
if(micros()-t_t2>1000000){
count--;
st2=2;
t_t2=micros();
}
}
if(st2==2){
if(micros()-t_t2>300000){
count--;
t_t2=micros();
}
}
}
else{
st2=0;
}
if(count>15){
count=0;
}
if(count<0){
count=15;
}
if(count&0x01){
digitalWrite(led4_pin,ON);
}
else{
digitalWrite(led4_pin,OFF);
}
if(count&0x02){
digitalWrite(led3_pin,ON);
}
else{
digitalWrite(led3_pin,OFF);
}
if(count&0x04){
digitalWrite(led2_pin,ON);
}
else{
digitalWrite(led2_pin,OFF);
}
if(count&0x08){
digitalWrite(led1_pin,ON);
}
else{
digitalWrite(led1_pin,OFF);
}
}