Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<arduinoPlatform.h>
- #include<tasks.h>
- #include<interrupts.h>
- #include<stdio.h>
- #include<serial.h>
- #include <pwm.h>
- #include<data.h>
- extern serial Serial;
- #define BTN 4
- int lastState_btn,
- startPressTime,
- click_counter = 0;
- void print_serial(){
- Serial.print("Broj klikova trenutno: ");
- Serial.println(click_counter);
- }
- void dugme(int id, void* ptrt){
- int newState = digitalRead(BTN);
- if(lastState_btn < newState){ //uzlazna ivica
- startPressTime = millis();
- lastState_btn = newState;
- }else if(lastState_btn > newState){ //silazna ivica
- if((millis() - startPressTime) >= 2000){
- click_counter++;
- print_serial();
- }
- lastState_btn = newState;
- }
- }
- void setup()
- {
- Serial.begin(9600);
- lastState_btn = digitalRead(BTN);
- createTask(dugme, 50, TASK_ENABLE, NULL);
- }
- void loop()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment