Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. int led_pins[8] = {2,3,4,5,6,7,8,9};
  2. int d = 500,lr = 1;
  3. int count = 128;
  4.  
  5. void setup() {
  6. Serial.begin(9600);
  7. // put your setup code here, to run once:
  8. for(int i = 0;i<7;i++){
  9. pinMode(led_pins[i],OUTPUT);
  10. }
  11. pinMode(10,INPUT);
  12. pinMode(11,INPUT);
  13.  
  14. }
  15.  
  16. void loop() {
  17. // put your main code here, to run repeatedly:
  18. Serial.write(count);
  19. for(int i = 0;i<7;i++){
  20. if(((count >> i) %2) ==1){
  21. digitalWrite(led_pins[i],HIGH);
  22. }
  23. else{
  24. digitalWrite(led_pins[i],LOW);
  25. }
  26. }
  27. if(digitalRead(9) == LOW){
  28. lr *= -1;
  29. Serial.write("aa");
  30. }
  31. if(lr == 1){
  32. if(count==1){
  33. count = 128;
  34. }else
  35. count >>= 1;
  36. }else{
  37. if(count == 128)
  38. count == 1;
  39. else
  40. count <<= 1;
  41. }
  42.  
  43. if(digitalRead(8) == HIGH){
  44. d = 200;
  45. }
  46. delay(d);
  47. d = 500;
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement