61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
/*
|
|
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
|
|
* An IR detector/demodulator must be connected to the input RECV_PIN.
|
|
* Version 0.1 July, 2009
|
|
* Copyright 2009 Ken Shirriff
|
|
* http://arcfn.com
|
|
*/
|
|
/* **************************************** *
|
|
* Title *
|
|
* **************************************** *
|
|
* (C) 201x-xx-xx Paolo Iocco *
|
|
* rev. 0.x *
|
|
* **************************************** *
|
|
* Circuit diagram
|
|
* ---------------
|
|
* +-------+
|
|
* | ooooo |
|
|
* D1--TX<----| A |<---------RAW
|
|
* D0--RX---->| r |<---------GND
|
|
* RST------->| d |<---------RST
|
|
* GND------->| u |<---------VCC
|
|
* D2-------->| i |-----A3---D17
|
|
* D3----#--->| n |-----A2---D16
|
|
* D4-------->| o |-----A1---D15
|
|
* D5<---#----| |-----A0---D14
|
|
* D6<---#----| m |-----SCK--D13
|
|
* D7---------| i |-----MISO-D12
|
|
* D8---------| n |--#--MOSI-D11
|
|
* D9----#----| i |--#--SS---D10
|
|
* +-------+
|
|
*
|
|
* ***************************************** */
|
|
|
|
#include <stdlib.h>
|
|
#include <IRremote.h>
|
|
#include "sys64738.h"
|
|
|
|
#define OLED_SDA 8
|
|
#define OLED_SCL 9
|
|
int RECV_PIN = 2;
|
|
|
|
IRrecv irrecv(RECV_PIN);
|
|
DisplayIIC OLED(OLED_SDA, OLED_SCL);
|
|
|
|
decode_results results;
|
|
|
|
void setup(){
|
|
Serial.begin(9600);
|
|
irrecv.enableIRIn(); // Start the receiver
|
|
}
|
|
|
|
void loop() {
|
|
char text[16];
|
|
if (irrecv.decode(&results)) {
|
|
Serial.println(results.value, HEX);
|
|
itoa(results.value,text,16);
|
|
OLED.WriteStringXY(0,0,text,FONT_6x8);
|
|
irrecv.resume(); // Receive the next value
|
|
}
|
|
}
|