wiki:wade/embedded/arduino/example/example_10_1_IR

回到 Arduino

Source code

void setup()
{
  pinMode(9, OUTPUT);
  //pinMode(8, OUTPUT);
  pinMode(2, INPUT);
}
boolean val1 = 1;
//boolean val2 = 1;
void loop()
{
  digitalWrite(9, val1^=1);
  //digitalWrite(8, val2^=1);
  if (digitalRead(2) == LOW)
    digitalWrite(13, HIGH);
  else
    digitalWrite(13, LOW);
  //delayMicroseconds(1);
}
Last modified 15 years ago Last modified on Apr 20, 2010, 11:35:00 PM