Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1.  
  2.  
  3. void setup() {
  4. // put your setup code here, to run once:
  5. Serial.begin(9600);
  6. for (int i=4;i<=7;i++){
  7. pinMode(i,OUTPUT);
  8. }
  9. }
  10.  
  11. int quotient = 0;
  12. int x = 0;
  13.  
  14.  
  15. void loop(){
  16. function2();
  17. encode();
  18. Serial.println(analogRead(A0));
  19.  
  20. }
  21.  
  22. void function1() {
  23. // put your main code here, to run repeatedly:
  24. x=16*millis()/500;
  25. quotient=x%16;
  26. }
  27.  
  28. void function2(){
  29. x=millis()/1000;
  30. if (x%2==0)
  31. quotient=15*(millis()%1000)/1000;
  32.  
  33. else
  34. quotient = 15-15*((millis()%1000))/1000;
  35.  
  36.  
  37. }
  38.  
  39. void encode(){
  40. for (int i=4;i<=7;i++){
  41. digitalWrite(i,quotient%2);
  42. quotient=quotient/2;
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement