Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int led_pins[8] = {2,3,4,5,6,7,8,9};
- int d = 500,lr = 1;
- int count = 128;
- void setup() {
- Serial.begin(9600);
- // put your setup code here, to run once:
- for(int i = 0;i<7;i++){
- pinMode(led_pins[i],OUTPUT);
- }
- pinMode(10,INPUT);
- pinMode(11,INPUT);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- Serial.write(count);
- for(int i = 0;i<7;i++){
- if(((count >> i) %2) ==1){
- digitalWrite(led_pins[i],HIGH);
- }
- else{
- digitalWrite(led_pins[i],LOW);
- }
- }
- if(digitalRead(9) == LOW){
- lr *= -1;
- Serial.write("aa");
- }
- if(lr == 1){
- if(count==1){
- count = 128;
- }else
- count >>= 1;
- }else{
- if(count == 128)
- count == 1;
- else
- count <<= 1;
- }
- if(digitalRead(8) == HIGH){
- d = 200;
- }
- delay(d);
- d = 500;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement