int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
for (int i=13; i>=7; i--) {
digitalWrite(i, HIGH);
delay(sensorValue/10);
}
for (int i=13; i>=7; i--) {
digitalWrite(i, LOW);
delay(sensorValue/10);
}
// digitalWrite(13, HIGH);
// delay(100);
// digitalWrite(12, HIGH);
// delay(100);
// digitalWrite(11, HIGH);
// delay(100);
// digitalWrite(10, HIGH);
// delay(100);
// digitalWrite(9, HIGH);
// delay(100);
// digitalWrite(8, HIGH);
// delay(100);
// digitalWrite(7, HIGH);
}
沒有留言:
張貼留言