📜  在arduino中使用ldr增加和减少led的亮度 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:51.299000             🧑  作者: Mango

代码示例1
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);
}