Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define botao1 9
- #define botao2 7
- #define botao3 10
- #define botao4 8
- #define botao5 13
- bool flag = 0;
- bool botao1pass = 0;
- bool botao2pass = 0;
- long tempo = 0;
- long tempo_pass = 0;
- void setup() {
- pinMode(botao1, INPUT);
- pinMode(botao2, INPUT);
- pinMode(botao3, INPUT);
- pinMode(botao4, INPUT);
- pinMode(botao5, INPUT);
- Serial.begin(9600);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- //.................TESTE...............................
- Serial.print("B1: ");
- Serial.print(Botao(botao1));
- Serial.print(" B2: ");
- Serial.print(Botao(botao2));
- Serial.print(" B3: ");
- Serial.print(Botao(botao3));
- Serial.print(" B4: ");
- Serial.print(Botao(botao4));
- Serial.print(" B5: ");
- Serial.println(Botao(botao5));
- }
- //.................FUNÇÃO BOTAO...............................
- bool Botao(int botao){
- bool estado;
- bool bot = digitalRead(botao);
- if(tempo - tempo_pass >= 50){
- estado = 1;
- if(bot == 0){
- tempo_pass = millis();
- }
- }
- else{
- estado = 0;
- }
- if(bot == 1){
- tempo = millis();
- }
- return estado;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement