Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #define clk 2
  2. #define dt 3
  3. #define grnd 6
  4.  
  5. bool direc;
  6. int count=0;
  7. void setup() {
  8. // put your setup code here, to run once:
  9. Serial.begin(9600);
  10. pinMode(dt,INPUT_PULLUP);
  11. pinMode(clk,INPUT_PULLUP);
  12. pinMode(grnd,OUTPUT);
  13. digitalWrite(grnd,0);
  14. pinMode(5, OUTPUT);
  15. digitalWrite(5, 1);
  16. pinMode(LED_BUILTIN, OUTPUT);
  17. digitalWrite(LED_BUILTIN,5);
  18. }
  19.  
  20. void loop() {
  21. // put your main code here, to run repeatedly:
  22.  
  23. if(digitalRead(clk) ==0){
  24.  
  25. direc = digitalRead(dt);
  26. if(direc == 0){
  27. count= count+5;
  28. Serial.println(count*2);
  29. Serial.println(direc);
  30. }else{
  31. count= count -5;
  32. Serial.println(count*2);
  33. Serial.println(direc*2);
  34.  
  35. }
  36.  
  37. delay(10);
  38. while(digitalRead(clk) ==0){
  39.  
  40. }
  41. analogWrite(LED_BUILTIN, count);
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement