Untitled

小夜燈photoresisterLED.ino
mail@pastecode.io avatar
unknown
plain_text
2 years ago
396 B
0
Indexable
Never
//photoresisterLED.ino
int data =-1;//光敏電阻回傳的資料
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);//D0
  Serial.begin(9600);
  
}

void loop() {
  // put your main code here, to run repeatedly:
  data = analogRead(A0);
  Serial.println(analogRead(A0));
  if(data<5){
    digitalWrite(LED_BUILTIN, LOW);//on
  }else{
    digitalWrite(LED_BUILTIN, HIGH);//off  
  }
}