2012年11月27日 星期二

Week12,HW10

影片一








影片二








影片三









影片四






[程式碼]
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
void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(13, OUTPUT); 
  pinMode(12, OUTPUT); 
  pinMode(11, OUTPUT); 
  pinMode(10, OUTPUT); 
  pinMode(9, OUTPUT); 
  pinMode(8, OUTPUT); 
  pinMode(7, OUTPUT); 
}
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);   
  // turn the ledPin on
 
  digitalWrite(13, HIGH); 
  delay(sensorValue/4);
  digitalWrite(11, LOW); 
  delay(sensorValue/4);
 
  digitalWrite(12, HIGH); 
  delay(sensorValue/4);
 
  digitalWrite(11, HIGH); 
  delay(sensorValue/4);
  digitalWrite(13, LOW); 
  delay(sensorValue/4);
 
  digitalWrite(10, HIGH); 
  delay(sensorValue/4);
  digitalWrite(12, LOW); 
  delay(sensorValue/4);
 
  digitalWrite(9, HIGH); 
  delay(sensorValue/4);
  digitalWrite(11, LOW); 
  delay(sensorValue/4);
 
  digitalWrite(8, HIGH); 
  delay(sensorValue/4);
  digitalWrite(10, LOW); 
  delay(sensorValue/4);
 
  digitalWrite(7, HIGH); 
  delay(sensorValue/4);
  digitalWrite(9, LOW); 
  delay(sensorValue/4);
 
  digitalWrite(9, HIGH); 
  delay(sensorValue/4);
  digitalWrite(7, LOW); 
  delay(sensorValue/4);
 
  digitalWrite(10, HIGH); 
  delay(sensorValue/4);
  digitalWrite(8, LOW); 
  delay(sensorValue/4);
 
  digitalWrite(11, HIGH); 
  delay(sensorValue/4);
  digitalWrite(9, LOW); 
  delay(sensorValue/4);
 
  digitalWrite(12, HIGH); 
  delay(sensorValue/4);
  digitalWrite(10, LOW); 
  delay(sensorValue/4);            
}

沒有留言:

張貼留言