#include <SPI.h>
#include <Wire.h> 
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <IRremote.h>

#define IR_RECEIVE_PIN 2

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1

#define test 34
#define retur 194
#define enter 168
#define up 2
#define down 152
#define left 224
#define right 144
#define zero_0 104
#define one_1 48
#define two_2 24
#define three_3 122
#define four_4 16
#define five_5 56
#define six_6 90
#define seven_7 66
#define eight_8 74
#define nine_9 82

char number_button_pressed;
int enter_button_pressed;
int up_button_pressed;
int down_button_pressed;
int left_button_pressed;
int right_button_pressed;
int asterisk_button_pressed;
int hash_button_pressed;


Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  IrReceiver.begin(IR_RECEIVE_PIN);
}

void loop() {
  if (IrReceiver.decode()) {
    button();
    IrReceiver.resume();
    Serial.print(number_button_pressed);
  }
  
}

void button () {
  switch (IrReceiver.decodedIRData.command) {
    case zero_0: {
      number_button_pressed = '0';
      break;
    }
    case one_1: {
      number_button_pressed = '1';
      break;
    }
    case two_2: {
      number_button_pressed = '2';
      break;
    }
    case three_3: {
      number_button_pressed = '3';
      break;
    }
    case four_4: {
      number_button_pressed = '4';
      break;
    }
    case five_5: {
      number_button_pressed = '5';
      break;
    }
    case six_6: {
      number_button_pressed = '6';
      break;
    }
    case seven_7: {
      number_button_pressed = '7';
      break;
    }
    case eight_8: {
      number_button_pressed = '8';
      break;
    }
    case nine_9: {
      number_button_pressed = '9';
      break;
    }
    default: {}
  }
}