Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 8 led chaser one direction with speed control via pot.
- int sensorValue = 0; //make a variable where you can store incoming
- //analog values
- void setup(){
- pinMode(13, OUTPUT);
- pinMode(12, OUTPUT); //tell arduino what you'll be using these pins
- pinMode(11, OUTPUT); // for (output).
- pinMode(10, OUTPUT);
- pinMode(9, OUTPUT);
- pinMode(8, OUTPUT);
- pinMode(7, OUTPUT);
- pinMode(6, OUTPUT);
- Serial.begin(9600); //initialize serial
- }
- void loop(){ //we put the code we want executed in a loop
- Serial.print("sensor = " ); //sends what's in quotes via serial
- Serial.println(sensorValue); //sends our variable (sensorValue)
- //via serial
- digitalWrite(13,HIGH); // lights the led
- sensorValue = analogRead(0); // reads pin 0
- delay(sensorValue + 25); // sensorValue used for delay
- digitalWrite(13,LOW); //turns off the led
- delay(15); //delay before moving to next output pin
- //the + 25 keeps delay from reaching zero
- //code below is for remaining 4 LEDs
- digitalWrite(12,HIGH);
- sensorValue = analogRead(0);
- delay(sensorValue + 25);
- digitalWrite(12, LOW);
- delay(15);
- digitalWrite(11,HIGH);
- sensorValue = analogRead(0);
- delay(sensorValue + 25);
- digitalWrite(11,LOW);
- delay(15);
- digitalWrite(10,HIGH);
- sensorValue = analogRead(0);
- delay(sensorValue + 25);
- digitalWrite(10,LOW);
- delay(15);
- digitalWrite(9,HIGH);
- sensorValue = analogRead(0);
- delay(sensorValue + 25);
- digitalWrite(9,LOW);
- delay(15);
- digitalWrite(8, HIGH);
- sensorValue = analogRead(0);
- delay(sensorValue + 25);
- digitalWrite(8, LOW);
- delay(15);
- digitalWrite(7,HIGH);
- sensorValue = analogRead(0);
- delay(sensorValue + 25);
- digitalWrite(7,LOW);
- delay(15);
- digitalWrite(6,HIGH);
- sensorValue = analogRead(0);
- delay(sensorValue + 25);
- digitalWrite(6,LOW);
- delay(15);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement