LMS知識社群歷程檔案Login
Position: 柯呈霖 > 未分類
12
by 柯呈霖 2020-04-22 11:07:46, Reply(1), Views(39)
123
Attachments:
Reply(1)

#define input A0

 

void setup(){

 Serial.begin(9600);

 for(int i = 4;i < 8;i++){

   pinMode(i, OUTPUT);

   digitalWrite(i, HIGH);

 }

}

 

void loop(){

  int temp = analogRead(input);

  int buf = map(temp, 200, 900, 0, 5);

 

  Serial.println(buf);

  Serial.println(temp);

  delay(300);

  for(int i=0;i<6;i++){

    if(i<=buf){

      digitalWrite(3+i, LOW); 

    } else {

      digitalWrite(3+i, HIGH);

    }

  }

}

 


Reply