Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void loop() {
- static int change = 0;
- static int pos = 0;
- static int oldPos = 0;
- //Read the Encoder's state
- encoder.tick();
- int enc = encoder.getPosition();
- change = oldPos - abs(enc) % 2;
- if (change != 0) {
- switch (i) {
- case 0:
- //do a program that lasts 5 seconds
- break;
- case 1:
- //do a program that lasts 5 seconds
- break;
- }
- oldPos = pos;
- change = 0;
- }
- }
Add Comment
Please, Sign In to add comment