unsigned long time1;
int analog_pin=A1;
int pwmled_pin=6;
int val;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val=analogRead(analog_pin);
val=map(val,0,1023,0,255);
if(millis()-time1>1000)
{
time1=millis();
Serial.println(val);
}
analogWrite(pwmled_pin,val);
}
沒有留言:
張貼留言