01.將霹靂燈錄影上傳到youtube,再貼回部落格
02.發揮你的創意做出最特別的霹靂燈
燈的顏色不一樣
03.貼上程式碼
/*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().
The circuit:
* Potentiometer attached to analog input 0
* center pin of the potentiometer to the analog pin
* one side pin (either one) to ground
* the other side pin to +5V
* LED anode (long leg) attached to digital output 13
* LED cathode (short leg) attached to ground
* Note: because most Arduinos have a built-in LED attached
to pin 13 on the board, the LED is optional.
Created by David Cuartielles
modified 30 Aug 2011
By Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/AnalogInput
*/
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().
The circuit:
* Potentiometer attached to analog input 0
* center pin of the potentiometer to the analog pin
* one side pin (either one) to ground
* the other side pin to +5V
* LED anode (long leg) attached to digital output 13
* LED cathode (short leg) attached to ground
* Note: because most Arduinos have a built-in LED attached
to pin 13 on the board, the LED is optional.
Created by David Cuartielles
modified 30 Aug 2011
By Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/AnalogInput
*/
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
int i=0;
void setup() {
Serial.begin(9600);
// declare the ledPin as an OUTPUT:
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
}
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
int i=0;
void setup() {
Serial.begin(9600);
// declare the ledPin as an OUTPUT:
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
Serial.println(sensorValue);
for(i=0;i<9;i++)
if(i==0);{
digitalWrite(13, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(13, LOW);
}
if(i==1);{
digitalWrite(12, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(12, LOW);
}
if(i==2);{
digitalWrite(11, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(11, LOW);
}
if(i==3);{
digitalWrite(10, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(10, LOW);
}
if(i==4);{
digitalWrite(9, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(9, LOW);
}
if(i==5);{
digitalWrite(10, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(10, LOW);
}
if(i==6);{
digitalWrite(11, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(11, LOW);
}
if(i==7);{
digitalWrite(12, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(12, LOW);
}
if(i==8);{
digitalWrite(13, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(13, LOW);
}
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}
*本週作業一組交一份即可(要標註組員姓名)
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
Serial.println(sensorValue);
for(i=0;i<9;i++)
if(i==0);{
digitalWrite(13, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(13, LOW);
}
if(i==1);{
digitalWrite(12, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(12, LOW);
}
if(i==2);{
digitalWrite(11, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(11, LOW);
}
if(i==3);{
digitalWrite(10, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(10, LOW);
}
if(i==4);{
digitalWrite(9, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(9, LOW);
}
if(i==5);{
digitalWrite(10, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(10, LOW);
}
if(i==6);{
digitalWrite(11, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(11, LOW);
}
if(i==7);{
digitalWrite(12, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(12, LOW);
}
if(i==8);{
digitalWrite(13, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(13, LOW);
}
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}
*本週作業一組交一份即可(要標註組員姓名)
沒有留言:
張貼留言