Guest User

Untitled

a guest
Feb 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. int state_1 = 1;
  2. int input_1 = digitalRead(PIN_1);
  3. int output_1;
  4.  
  5. edge_detect(input_1,&state_1,&output_1);
  6.  
  7.  
  8. void edge_detect(int input, int* button_state, int* output) {
  9. int theOutput = *output
  10. int bState = *button_state;
  11. if (bState == 1 && input == 0){
  12. theOutput = 1;
  13. bState = 0;
  14. }
  15. else if (bState == 0 && input == 1){
  16. theOutput = -1;
  17. bState = 1;
  18. }
  19. else{
  20. theOutput = 0;
  21. }
  22. }
Add Comment
Please, Sign In to add comment