|
楼主 |
发表于 2018-2-8 13:35
|
显示全部楼层
void setup()
{
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(A0, INPUT);
}
void loop()
{
int i=analogRead(A0);
if(i>120)
{
analogWrite(8,1000);
analogWrite(9,255);
delay(500);
analogWrite(8,500);
analogWrite(9,100);
delay(500) ;
Serial.println(i);
}
else
{
analogWrite(8,0);
analogWrite(9,0);
Serial.println(i);
delay(1000);
}
} |
|