March 19, 2015

Uniden "U-Control" v2.0

Rewrote the code from start to finish, Now at v2.0 Will add volume and mute control in the next update and try to port this over to the ATTINY85 board. Code is posted below. Went from about 200 lines of code to 43.

















 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "IRremote.h"//Library github.com/shirriff/Arduino-IRremote
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver);
decode_results results;
void setup()
{
  Serial.begin(9600);
  Serial.println("IR Receiver Raw Data + Button Decode Test");
  irrecv.enableIRIn();
}
void loop()
{
  if (irrecv.decode(&results))
  {
    Serial.println(results.value, DEC);
    translateIR();
    irrecv.resume();
  }
}
void translateIR()
{
  switch (results.value)
  {
   
    case 2499: Serial.print("KEY,S,P"); break;//SCAN
    case 2502: Serial.print("KEY,>,P"); break;//SCAN UP
    case 2508: Serial.print("KEY,<,P"); break;//SCAN DOWN
    case 2501: Serial.print("KEY,H,P"); break;//HOLD & RESUME
    case 2511: Serial.print("KEY,1,L"); break;//GROUP 1
    case 2517: Serial.print("KEY,2,L"); break;//GROUP 2
    case 2512: Serial.print("KEY,3,L"); break;//GROUP 3
    case 2520: Serial.print("KEY,4,L"); break;//GROUP 4
    case 2523: Serial.print("KEY,5,L"); break;//GROUP 5
    case 2526: Serial.print("KEY,6,L"); break;//GROUP 6
    case 2513: Serial.print("KEY,7,L"); break;//GROUP 7
    case 2529: Serial.print("KEY,8,L"); break;//GROUP 8
    case 2514: Serial.print("KEY,9,L"); break;//GROUP 9
    case 2535: Serial.print("KEY,0,L"); break;//GROUP 0
    default: Serial.println(" Unmapped Button");
    Serial.flush();
  }
  delay(100);
}

No comments:

Post a Comment