Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int analogPin = 0;
- const int ledCount = 10;
- int ledPins[]={
- 2,3,4,5,6,7,8,9,10,11
- };
- void setup(){
- for(int thisLed= 0;thisLed<ledCount;thisLed++){
- pinMode(ledPins[thisLed],OUTPUT);
- }
- }
- void loop(){
- int sensorReading = analogRead(analogPin);
- int ledLevel = map(sensorReading,0,1023,0,ledCount);
- for(int thisLed=0;thisLed<ledCount;thisLed++){
- if(thisLed<ledLevel){
- digitalWrite(ledPins[thisLed],HIGH);
- }
- else{
- digitalWrite(ledPins[thisLed],LOW);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement