int led_pin=2;
int analog_pin = 0;
int value;
void setup()
{
Serial.begin(9600);
pinMode(led_pin,OUTPUT);
}
void loop()
{
value=analogRead(analog_pin);
value=map(value,0,1023,0,100);
Serial.println(100-value);
digitalWrite(led_pin,HIGH);delay(100-value);
digitalWrite(led_pin,LOW);delay(100-value);
}
沒有留言:
張貼留言