红外传感器

红外传感器 示例代码

#include<IRremote.h>

long ir_value;
IRrecv iRrecv(A0);
decode_results results;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  iRrecv.enableIRIn();
}

void loop() {
  // put your main code here, to run repeatedly:
  if(iRrecv.decode(&results)){
    ir_value=results.value;
    Serial.println(ir_value,HEX);
    iRrecv.resume();
  }
}
posted @ 2022-12-11 14:07  new-code  阅读(237)  评论(0)    收藏  举报