Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. void setup(){
  2. Serial.begin(9600);
  3. for (int i=4; i<=7; i++){
  4. pinMode(i,OUTPUT);
  5. }
  6. }
  7. int quotient = 0;
  8. int x = 0;
  9. void loop(){
  10. function1();
  11. encode();
  12. }
  13. void function1(){
  14. x = x+16*millis()/100;
  15. quotient = x%16;
  16. }
  17. void function2(){
  18. x = millis()/50;
  19. if (x%2==0) quotient=15*(millis()%50)/50;
  20. else quotient = 15*(1-(millis()%50)/50);
  21. }
  22. void encode(){
  23. for (int i=4; i<=7, i++){
  24. digitalWrite(i,quotient%2);
  25. quotient = quotient/2;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement