📅  最后修改于: 2022-03-11 14:59:51.299000             🧑  作者: Mango
int ledpin = 9;int ldrpin = 1;
int value = 0;void setup()
{Serial.begin(9600);}
void loop()
{
value = analogRead(ldrpin);
value = constrain(value,400,500);
value = map(value,400,500,255,0); Serial.println(value);
analogWrite(ledpin, value); delay(200);
}