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(11, OUTPUT);
  pinMode(9, OUTPUT); 
  pinMode(7, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(1, OUTPUT); 
}
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);   
  // turn the ledPin on
  digitalWrite(13, HIGH); 
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);         
  // turn the ledPin off:       
  digitalWrite(13, LOW);  
   digitalWrite(11, HIGH); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);   
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, HIGH); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, HIGH); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, HIGH); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, HIGH); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, HIGH); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);    
   digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, HIGH); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);   
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, HIGH); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, HIGH); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, HIGH); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, HIGH); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, HIGH);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);    
}

沒有留言:

張貼留言