Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int state_1 = 1;
- int input_1 = digitalRead(PIN_1);
- int output_1;
- edge_detect(input_1,&state_1,&output_1);
- void edge_detect(int input, int* button_state, int* output) {
- int theOutput = *output
- int bState = *button_state;
- if (bState == 1 && input == 0){
- theOutput = 1;
- bState = 0;
- }
- else if (bState == 0 && input == 1){
- theOutput = -1;
- bState = 1;
- }
- else{
- theOutput = 0;
- }
- }
Add Comment
Please, Sign In to add comment