1. 七彩霓虹燈影片
2. 我們做了持續閃爍的七彩霓虹燈
3. 程式碼
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 7; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(1, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(1, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(1, LOW);
delay(100);
delay(50);
}
4. 心得
今天的七彩霓虹燈非常有趣,感謝森哥的照料與支持,我們將會更加茁壯努力再出發!
沒有留言:
張貼留言