wiki:wade/embedded/arduino/example/example_10_1_IR

Version 2 (modified by wade, 15 years ago) (diff)

--

回到 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);
}