当前位置:首页 > Arduino红外遥控实验例子
long off1 = 0x00FFE01F; long on2 = 0x00FF629D; long off2 = 0x00FFA857; long on3 = 0x00FFE21D; long off3 = 0x00FF906F; long on4 = 0x00FF22DD; long off4 = 0x00FF6897; long on5 = 0x00FF02FD; long off5 = 0x00FF9867; long on6 = 0x00FFC23D; long off6 = 0x00FFB047; IRrecv irrecv(RECV_PIN); decode_results results;
// Dumps out the decode_results structure. // Call this after IRrecv::decode() // void * to work around compiler issue //void dump(void *v) {
// decode_results *results = (decode_results *) void dump(decode_results *results) { int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.println(\ } else {
if (results->decode_type == NEC) {
Serial.print(\ }
else if (results->decode_type == SONY) {
Serial.print(\ }
else if (results->decode_type == RC5) {
Serial.print(\ }
else if (results->decode_type == RC6) {
Serial.print(\ }
Serial.print(results->value, HEX); Serial.print(\
Serial.print(results->bits, DEC); Serial.println(\ }
Serial.print(\ Serial.print(count, DEC); Serial.print(\
for (int i = 0; i < count; i++) {
if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC); } else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC); }
Serial.print(\ }
Serial.println(\ }
void setup()
{
pinMode(RECV_PIN, INPUT); pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); pinMode(LED4, OUTPUT); pinMode(LED5, OUTPUT); pinMode(LED6, OUTPUT); pinMode(13, OUTPUT); Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver }
int on = 0;
unsigned long last = millis();
void loop() {
if (irrecv.decode(&results)) {
// If it's been at least 1/4 second since the last
共分享92篇相关文档