Skip to content

Instantly share code, notes, and snippets.

@mpflaga
Last active February 14, 2024 18:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpflaga/6091076 to your computer and use it in GitHub Desktop.
Save mpflaga/6091076 to your computer and use it in GitHub Desktop.
TinyIRdual - code for home made Magic Wand Kiosk reciever, using a DigiSpark (ATtiny85) Arduino
/*
* TinyIRDuel: IRrecvDump - dump details of IR codes with IRrecv
* IR detector/demodulator must be connected to the input RECV_PIN.
* IR Transmitter to JAM must be connected ot
* Version 0.1 July, 2013
* Author: 2013 Michael P. Flaga
*/
//List of wand ID's
#define WAND_RED1 0x1AEDC601
#define WAND_BLU1 0x18C04B01
#define WAND_BRWN 0x02DE5081
#define WAND_RED2 0x2C578081
#define WAND_BLU2 0x04FAB881
#define WAND_PINK 0x19D1DD01
#include <IRremote.h> //https://github.com/mpflaga/Arduino-IRremote.git
int RECV_PIN = 2;
int LED_TX_PIN = 1;
int LED_YELLOW_PIN = 0;
int LED_BLUE_PIN = 5;
int BUZZER_PIN = 4;
int blink_rate = 125;
int blink_number = 20;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
pinMode(LED_TX_PIN, OUTPUT);
pinMode(LED_YELLOW_PIN, OUTPUT);
pinMode(LED_BLUE_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
irrecv.enableIRIn(); // Start the receiver
digitalWrite(BUZZER_PIN, HIGH);
for (int i = 0; i < 20; i++) {
digitalWrite(LED_YELLOW_PIN, HIGH);
digitalWrite(LED_BLUE_PIN, LOW);
delay(blink_rate/2);
digitalWrite(LED_YELLOW_PIN, LOW);
digitalWrite(LED_BLUE_PIN, HIGH);
delay(blink_rate/2);
}
digitalWrite(LED_YELLOW_PIN, LOW);
digitalWrite(LED_BLUE_PIN, LOW);
digitalWrite(BUZZER_PIN, LOW);
}
void dump(decode_results *results) {
if (results->decode_type == MAGIQUEST) {
switch (results->value) {
case WAND_RED1:
case WAND_BLU1:
case WAND_BRWN:
looser();
break;
case WAND_RED2:
case WAND_BLU2:
case WAND_PINK:
winner();
break;
}
}
}
void loop() {
if (irrecv.decode(&results)) {
dump(&results);
irrecv.resume(); // Receive the next value
}
}
void winner() {
tone(LED_TX_PIN, 39000);
digitalWrite(BUZZER_PIN, HIGH);
for (int i = 0; i < blink_number; i++) {
digitalWrite(LED_YELLOW_PIN, HIGH);
digitalWrite(LED_BLUE_PIN, LOW);
delay(blink_rate);
digitalWrite(LED_YELLOW_PIN, LOW);
digitalWrite(LED_BLUE_PIN, HIGH);
delay(blink_rate);
}
digitalWrite(LED_BLUE_PIN, LOW);
noTone(LED_TX_PIN);
digitalWrite(BUZZER_PIN, LOW);
}
void looser() {
//tone(LED_TX_PIN, 39000);
digitalWrite(LED_YELLOW_PIN, HIGH);
digitalWrite(LED_BLUE_PIN, HIGH);
for (int i = 0; i < blink_number; i++) {
delay(blink_rate * 2);
}
digitalWrite(LED_YELLOW_PIN, LOW);
digitalWrite(LED_BLUE_PIN, LOW);
//noTone(LED_TX_PIN);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment