reorganizing project to more general synchronizer in preparation for export/delivery to RVK museum.

This commit is contained in:
foley@ru.is
2013-09-22 16:58:16 +00:00
parent 10423b4755
commit 138877a1ef
33 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
/* DVD IR Synchronizer for Philips DVP3142/12
* Developed for Art Installation "Thor"
* Code written by Joe Foley <foley@ru.is>
* on 2013-09-08
*
*
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
* Instructions http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
*
* IR Remote codes from IRrecvDemo
*
*
* Details on the Philips RC6 coding
* http://www.pcbheaven.com/userpages/The_Philips_RC6_Protocol/
*
* The IRremote library uses Pin 3 for the Anode (longer pin)
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*/
#include <IRremote.h>
int pinGND=4; // Longer leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int heartbeat=0;
int secs;
// Sarcity 20:58
int playtime= 58*44+10; // Play time in seconds, you usually leave off a second or two
//int playtime= 10; // testing
IRsend irsend;
void setup() {
pinMode(pinGND,OUTPUT);
pinMode(pinLED,OUTPUT);
Serial.begin(115200);
Serial.println("Panasonic DVD DVP-3142/12 Synchronizer $Rev$");
Serial.println("For \"Sarcity\" by Thor Elis (1981)");
Serial.println("Code by Joe Foley <foley@ru.is>");
Serial.println("$URL$");
Serial.println("$Id$");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
secs=playtime;
send_play();
}
/********************************************************************/
void loop() {
Serial.println("Sync");
//send_pause();
//waitsec(2);
// The three players don't always see the "previous command" so we send it multiple times
send_previous();
send_previous();
send_previous();
//waitsec(2);
// Don't send play because previous automatically starts it
// If we hit play it will merely pause it.
//send_play();
for(int t = 0; t < playtime; t++) {
// This will not give us perfect 1 second timing
// but it is good enough for most video applications
// The most critical is having everything start at the
// same time.
Serial.print("sec:");
Serial.print(playtime);
Serial.print(" / mm:ss ");
Serial.print(t/60);
Serial.print(":");
Serial.print(t % 60);
Serial.println("");
if (heartbeat == 1) {
digitalWrite(pinLED, HIGH);
heartbeat = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat = 1;
}
delay(1000);
}
}
/**************************************************************/
void waitsec(int sec) {
Serial.print("Wait ");
Serial.print(sec);
Serial.println(" seconds");
delay(sec*1000);
}
/********************************************************************/
void send_stop() {
// First comes the pre-data bits, then the command code
Serial.println(" stop");
irsend.sendRC6(0x10431,20);
}
/********************************************************************/
void send_play() {
// First comes the pre-data bits, then the command code
Serial.println(" play");
irsend.sendRC6(0x1042C,20);
}
/********************************************************************/
void send_pause() {
// First comes the pre-data bits, then the command code
Serial.println(" pause");
irsend.sendRC6(0x1042C,20);
}
/********************************************************************/
void send_previous() {
// First comes the pre-data bits, then the command code
Serial.println(" previous");
irsend.sendRC6(0x10421, 20);
}

View File

@@ -0,0 +1,130 @@
/* DVD IR Synchronizer for Philips DVP3142/12
* Developed for Art Installation "West"
* Code written by Joe Foley <foley@ru.is>
* on 2013-09-08
*
*
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
* Instructions http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
*
* IR Remote codes from IRrecvDemo
*
* The IRremote library uses Pin 3 for the Anode (longer pin)
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*/
#include <IRremote.h>
int pinGND=4; // Longer leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int heartbeat=0;
int secs;
// West 25:41
int playtime= 25*60+40; // Play time in seconds, you usually leave off a second or two
//int playtime= 10; // testing
IRsend irsend;
void setup() {
pinMode(pinGND,OUTPUT);
pinMode(pinLED,OUTPUT);
Serial.begin(115200);
Serial.println("Scott DVX605 HD(Rev2) Synchronizer $Rev$");
Serial.println("For \"West\" by Steina Vasulka (1983)");
Serial.println("Code by Joe Foley <foley@ru.is>");
Serial.println("$URL$");
Serial.println("$Id$");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
secs=playtime;
}
/********************************************************************/
void loop() {
Serial.println("Sync");
//send_pause();
//waitsec(2);
send_previous();
send_previous();
send_previous();
//waitsec(2);
// Don't send play because previous automatically starts it
// If we hit play it will merely pause it.
//send_play();
for(int t = 0; t < playtime; t++) {
// This will not give us perfect 1 second timing
// but it is good enough for most video applications
// The most critical is having everything start at the
// same time.
Serial.print("sec:");
Serial.print(playtime);
Serial.print(" / mm:ss ");
Serial.print(t/60);
Serial.print(":");
Serial.print(t % 60);
Serial.println("");
if (heartbeat == 1) {
digitalWrite(pinLED, HIGH);
heartbeat = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat = 1;
}
delay(1000);
}
}
/**************************************************************/
void waitsec(int sec) {
Serial.print("Wait ");
Serial.print(sec);
Serial.println(" seconds");
delay(sec*1000);
}
/********************************************************************/
void send_stop() {
// First comes the pre-data bits, then the command code
Serial.println(" stop");
irsend.sendNEC(0xFFC837,32);
}
/********************************************************************/
void send_play() {
// First comes the pre-data bits, then the command code
Serial.println(" play");
irsend.sendNEC(0xFFF00F,32);
}
/********************************************************************/
void send_pause() {
// First comes the pre-data bits, then the command code
Serial.println(" pause");
irsend.sendNEC(0xFFD02F,32);
}
/********************************************************************/
void send_previous() {
// First comes the pre-data bits, then the command code
Serial.println(" previous");
irsend.sendNEC(0xFF50AF, 32);
}

View File

@@ -0,0 +1,132 @@
/* DVD IR Synchronizer for Toshiba SD1091EKE
* Developed for Art Installation by Steina
* Code written by Joe Foley <foley@ru.is>
* on 2013-09-08
*
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
*
* More codes at http://www.lirc.org/
* The compatible remote is SE-R0301
* We use the codes for the SE-R0031
* http://lirc.sourceforge.net/remotes/toshiba/SE-R0031
* Note that this has some similar codes
*
* The IRremote library uses Pin 3 for the Anode (longer pin)
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*
*
*/
#include <IRremote.h>
int pinGND=4; // Longer leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int secs;
int heartbeat=0;
// West 25:41
int playtime= 25*60+40; // set here your DVD title playtime in sec leave a little extra
IRsend irsend;
void setup() {
pinMode(pinGND,OUTPUT);
pinMode(pinLED,OUTPUT);
Serial.begin(115200);
Serial.println("Toshiba DVD SD1091EKE Synchronizer $Rev$");
Serial.println("For \"West\" by Steina Vasulka (1983)");
Serial.println("Code by Joe Foley <foley@ru.is>");
Serial.println("$URL$");
Serial.println("$Id$");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
secs=playtime;
}
/********************************************************************/
void loop() {
Serial.println("Sync");
// The DVD player starts playing automatically, so we should pause it
send_pause();
waitsec(2);
send_previous();
// on this model, previous immediately starts playing
for(int t = 0; t < playtime; t++) {
// This will not give us perfect 1 second timing
// but it is good enough for most video applications
// The most critical is having everything start at the
// same time.
Serial.print("sec:");
Serial.print(playtime);
Serial.print(" / mm:ss ");
Serial.print(t/60);
Serial.print(":");
Serial.print(t % 60);
Serial.println("");
if (heartbeat == 1) {
digitalWrite(pinLED, HIGH);
heartbeat = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat = 1;
}
delay(1000);
}
}
/**************************************************************/
void waitsec(int sec) {
Serial.print("Wait ");
Serial.print(sec);
Serial.println(" seconds");
delay(sec*1000);
}
/********************************************************************/
// NEC data format: first comes the pre-data bits, then the command code
void send_stop() {
Serial.println(" stop");
irsend.sendNEC(0xA25D28D7,32);
}
/********************************************************************/
void send_play() {
// Note that play and pause are a toggle for the same command
Serial.println(" play");
irsend.sendNEC(0xA25DA857, 32);
}
/********************************************************************/
void send_pause() {
// On this model, pause and play are the same button so it toggles
// We use the "step" command which will always pause, no matter
// how many times we press it.
Serial.println(" step/pause");
irsend.sendNEC(0xA25D00FF,32);
}
/********************************************************************/
void send_previous() {
// First comes the pre-data bits, then the command code
Serial.println(" previous");
irsend.sendNEC(0xA25DC43B, 32);
}

View File

@@ -0,0 +1,126 @@
/* DVD IR Synchronizer for Toshiba SD590EKE
* Developed for Art Installation "Dawn" by Sigrun Hardardottir<sigrun@stalverk.is>
* Code written by Joe Foley <foley@ru.is>
* on 2013-09-08
*
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
*
* IR Remote codes from SE-R0313
* http://lirc.sourceforge.net/remotes/toshiba/SE-R0313
*
* The IRremote library uses Pin 3 for the Anode (longer pin)
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*/
#include <IRremote.h>
int pinGND=4; // Longer leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int heartbeat=0;
int secs;
// Dawn 61:36
int playtime= 61*60+35; // set here your DVD title playtime in sec leave a little extra
IRsend irsend;
void setup() {
pinMode(pinGND,OUTPUT);
pinMode(pinLED,OUTPUT);
Serial.begin(115200);
Serial.println("Toshiba DVD SD590EKE Synchronizer $Rev$");
Serial.println("For \"Dawn\" by Sigrun Hardar on 1986");
Serial.println("Code by Joe Foley <foley@ru.is>");
Serial.println("$URL$");
Serial.println("$Id$");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
// The DVD player starts playing automatically, so maybe we should pause it
//send_pause();
//waitsec(2);
secs=playtime;
}
/********************************************************************/
void loop() {
Serial.println("Sync");
send_pause();
waitsec(2);
send_previous();
//waitsec(2);
//send_play(); // this should not be necessary, but just in case
for(int t = 0; t < playtime; t++) {
// This will not give us perfect 1 second timing
// but it is good enough for most video applications
// The most critical is having everything start at the
// same time.
Serial.print("sec:");
Serial.print(playtime);
Serial.print(" / mm:ss ");
Serial.print(t/60);
Serial.print(":");
Serial.print(t % 60);
Serial.println("");
if (heartbeat == 1) {
digitalWrite(pinLED, HIGH);
heartbeat = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat = 1;
}
delay(1000);
}
}
/**************************************************************/
void waitsec(int sec) {
Serial.print("Wait ");
Serial.print(sec);
Serial.println(" seconds");
delay(sec*1000);
}
/********************************************************************/
void send_stop() {
// First comes the pre-data bits, then the command code
Serial.println(" stop");
irsend.sendNEC(0xA25D28D7,32);
}
/********************************************************************/
void send_play() {
// First comes the pre-data bits, then the command code
Serial.println(" play");
irsend.sendNEC(0xA25DA857,32);
}
/********************************************************************/
void send_pause() {
// First comes the pre-data bits, then the command code
Serial.println(" pause");
irsend.sendNEC(0xA25D00FF, 32);
}
/********************************************************************/
void send_previous() {
// First comes the pre-data bits, then the command code
Serial.println(" previous");
irsend.sendNEC(0xA25DC43B, 32);
}

View File

@@ -0,0 +1,29 @@
/*
* IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
* An IR LED must be connected to Arduino PWM pin 3.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
*/
#include <IRremote.h>
#define PanasonicAddress 0x4004 // Panasonic address (Pre data)
#define PanasonicPower 0x100BCBD // Panasonic Power button
#define JVCPower 0xC5E8
IRsend irsend;
void setup()
{
}
void loop() {
irsend.sendPanasonic(PanasonicAddress,PanasonicPower); // This should turn your TV on and off
irsend.sendJVC(JVCPower, 16,0); // hex value, 16 bits, no repeat
delayMicroseconds(50); // see http://www.sbprojects.com/knowledge/ir/jvc.php for information
irsend.sendJVC(JVCPower, 16,1); // hex value, 16 bits, repeat
delayMicroseconds(50);
}

View File

@@ -0,0 +1,75 @@
\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage[newdimens]{labels}
\usepackage{SIunits}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage[icelandic]{babel}
\LabelCols=2 %
\LabelRows=6 %
\LeftPageMargin=8mm %
\RightPageMargin=8mm %
\TopPageMargin=21mm %
\BottomPageMargin=21mm %
\InterLabelColumn=0mm %
\InterLabelRow=0mm %
\LeftLabelBorder=5mm %
\RightLabelBorder=5mm %
\TopLabelBorder=5mm %
\BottomLabelBorder=5mm %
%\LabelInfotrue % debugging the sheet
%\LabelGridtrue % for debugging an individual label box
% 2 labels for each side
\numberoflabels=2
% change the font
\newcommand{\bigfont}{
\fontencoding{T1}
\fontfamily{cmr}
\fontseries{m}
\fontshape{n}
\fontsize{17}{20}
\selectfont
}
\begin{document}
%\SetLabel{103mm}{127mm}{10.5mm}{10mm}{13mm}{2}{2}
\newcommand{\lab}[3]{%
\genericlabel{
\begin{minipage}{85mm}
{\centering\Large\bf #1}\hfill{\tiny\today}\includegraphics[height=8mm]{RU-logo}\vspace{2pt}\hrule
% \begin{minipage}{75mm}
\vspace*{0.1in}
% {\large #2}\\
{\bf #2}\\
#3
% \end{minipage}
\end{minipage}
}
}
\newcommand{\labnoru}[4]{%
\genericlabel{
\begin{minipage}{85mm}
{\centering\Large\bf #1}\hfill{\small#4}\vspace{2pt}\hrule
% \begin{minipage}{75mm}
\vspace*{0.1in}
% {\large #2}\\
{\bf #2}\\
#3
% \end{minipage}
\end{minipage}
}
}
% blanks for partial sheets
%\lab{}{}{}{}
%\lab{}{}{}{}
%\lab{}{}{}{}
%\lab{}{}{}{}
\newcommand{\syncdesigner}{Synchronizer\\by Joe Foley $<$foley@ru.is$>$ +354-661-7658}
\labnoru{Dawn (6:09)}{By Sigrún Harðar}{Toshiba SD590EKE \syncdesigner}{1986}
\labnoru{Sarcity (20:58)}{By Þor Elís}{Philips DVP3142 \syncdesigner}{1981}
\labnoru{West (25:42)}{By Steina Vasulka}{Toshiba SD1091EKE \syncdesigner}{1983}
%\input{label-input.tex}
\end{document}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,118 @@
/*
* IRremote
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.htm http://arcfn.com
* Edited by Mitra to add new controller SANYO
*
* Interrupt code based on NECIRrcv by Joe Knapp
* http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
*
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
*/
#ifndef IRremote_h
#define IRremote_h
// The following are compile-time library options.
// If you change them, recompile the library.
// If DEBUG is defined, a lot of debugging output will be printed during decoding.
// TEST must be defined for the IRtest unittests to work. It will make some
// methods virtual, which will be slightly slower, which is why it is optional.
// #define DEBUG
// #define TEST
// Results returned from the decoder
class decode_results {
public:
int decode_type; // NEC, SONY, RC5, UNKNOWN
unsigned int panasonicAddress; // This is only used for decoding Panasonic data
unsigned long value; // Decoded value
int bits; // Number of bits in decoded value
volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks
int rawlen; // Number of records in rawbuf.
};
// Values for decode_type
#define NEC 1
#define SONY 2
#define RC5 3
#define RC6 4
#define DISH 5
#define SHARP 6
#define PANASONIC 7
#define JVC 8
#define SANYO 9
#define MITSUBISHI 10
#define UNKNOWN -1
// Decoded value for NEC when a repeat code is received
#define REPEAT 0xffffffff
// main class for receiving IR
class IRrecv
{
public:
IRrecv(int recvpin);
void blink13(int blinkflag);
int decode(decode_results *results);
void enableIRIn();
void resume();
private:
// These are called by decode
int getRClevel(decode_results *results, int *offset, int *used, int t1);
long decodeNEC(decode_results *results);
long decodeSony(decode_results *results);
long decodeSanyo(decode_results *results);
long decodeMitsubishi(decode_results *results);
long decodeRC5(decode_results *results);
long decodeRC6(decode_results *results);
long decodePanasonic(decode_results *results);
long decodeJVC(decode_results *results);
long decodeHash(decode_results *results);
int compare(unsigned int oldval, unsigned int newval);
}
;
// Only used for testing; can remove virtual for shorter code
#ifdef TEST
#define VIRTUAL virtual
#else
#define VIRTUAL
#endif
class IRsend
{
public:
IRsend() {}
void sendNEC(unsigned long data, int nbits);
void sendSony(unsigned long data, int nbits);
// Neither Sanyo nor Mitsubishi send is implemented yet
// void sendSanyo(unsigned long data, int nbits);
// void sendMitsubishi(unsigned long data, int nbits);
void sendRaw(unsigned int buf[], int len, int hz);
void sendRC5(unsigned long data, int nbits);
void sendRC6(unsigned long data, int nbits);
void sendDISH(unsigned long data, int nbits);
void sendSharp(unsigned long data, int nbits);
void sendPanasonic(unsigned int address, unsigned long data);
void sendJVC(unsigned long data, int nbits, int repeat); // *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does.
// private:
void enableIROut(int khz);
VIRTUAL void mark(int usec);
VIRTUAL void space(int usec);
}
;
// Some useful constants
#define USECPERTICK 50 // microseconds per clock interrupt tick
#define RAWBUF 100 // Length of raw duration buffer
// Marks tend to be 100us too long, and spaces 100us too short
// when received due to sensor lag.
#define MARK_EXCESS 100
#endif

View File

@@ -0,0 +1,464 @@
/*
* IRremote
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
*
* Modified by Paul Stoffregen <paul@pjrc.com> to support other boards and timers
*
* Interrupt code based on NECIRrcv by Joe Knapp
* http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
*
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
*/
#ifndef IRremoteint_h
#define IRremoteint_h
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
// define which timer to use
//
// Uncomment the timer you wish to use on your board. If you
// are using another library which uses timer2, you have options
// to switch IRremote to use a different timer.
// Arduino Mega
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
//#define IR_USE_TIMER1 // tx = pin 11
#define IR_USE_TIMER2 // tx = pin 9
//#define IR_USE_TIMER3 // tx = pin 5
//#define IR_USE_TIMER4 // tx = pin 6
//#define IR_USE_TIMER5 // tx = pin 46
// Teensy 1.0
#elif defined(__AVR_AT90USB162__)
#define IR_USE_TIMER1 // tx = pin 17
// Teensy 2.0
#elif defined(__AVR_ATmega32U4__)
//#define IR_USE_TIMER1 // tx = pin 14
//#define IR_USE_TIMER3 // tx = pin 9
#define IR_USE_TIMER4_HS // tx = pin 10
// Teensy++ 1.0 & 2.0
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
//#define IR_USE_TIMER1 // tx = pin 25
#define IR_USE_TIMER2 // tx = pin 1
//#define IR_USE_TIMER3 // tx = pin 16
// Sanguino
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
//#define IR_USE_TIMER1 // tx = pin 13
#define IR_USE_TIMER2 // tx = pin 14
// Atmega8
#elif defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__)
#define IR_USE_TIMER1 // tx = pin 9
#elif defined( __AVR_ATtinyX4__ )
#define IR_USE_TIMER1 // tx = pin 6
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc
#else
//#define IR_USE_TIMER1 // tx = pin 9
#define IR_USE_TIMER2 // tx = pin 3
#endif
#ifdef F_CPU
#define SYSCLOCK F_CPU // main Arduino clock
#else
#define SYSCLOCK 16000000 // main Arduino clock
#endif
#define ERR 0
#define DECODED 1
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
// Pulse parms are *50-100 for the Mark and *50+100 for the space
// First MARK is the one after the long gap
// pulse parameters in usec
#define NEC_HDR_MARK 9000
#define NEC_HDR_SPACE 4500
#define NEC_BIT_MARK 560
#define NEC_ONE_SPACE 1600
#define NEC_ZERO_SPACE 560
#define NEC_RPT_SPACE 2250
#define SONY_HDR_MARK 2400
#define SONY_HDR_SPACE 600
#define SONY_ONE_MARK 1200
#define SONY_ZERO_MARK 600
#define SONY_RPT_LENGTH 45000
#define SONY_DOUBLE_SPACE_USECS 500 // usually ssee 713 - not using ticks as get number wrapround
// SA 8650B
#define SANYO_HDR_MARK 3500 // seen range 3500
#define SANYO_HDR_SPACE 950 // seen 950
#define SANYO_ONE_MARK 2400 // seen 2400
#define SANYO_ZERO_MARK 700 // seen 700
#define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround
#define SANYO_RPT_LENGTH 45000
// Mitsubishi RM 75501
// 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7
// #define MITSUBISHI_HDR_MARK 250 // seen range 3500
#define MITSUBISHI_HDR_SPACE 350 // 7*50+100
#define MITSUBISHI_ONE_MARK 1950 // 41*50-100
#define MITSUBISHI_ZERO_MARK 750 // 17*50-100
// #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround
// #define MITSUBISHI_RPT_LENGTH 45000
#define RC5_T1 889
#define RC5_RPT_LENGTH 46000
#define RC6_HDR_MARK 2666
#define RC6_HDR_SPACE 889
#define RC6_T1 444
#define RC6_RPT_LENGTH 46000
#define SHARP_BIT_MARK 245
#define SHARP_ONE_SPACE 1805
#define SHARP_ZERO_SPACE 795
#define SHARP_GAP 600000
#define SHARP_TOGGLE_MASK 0x3FF
#define SHARP_RPT_SPACE 3000
#define DISH_HDR_MARK 400
#define DISH_HDR_SPACE 6100
#define DISH_BIT_MARK 400
#define DISH_ONE_SPACE 1700
#define DISH_ZERO_SPACE 2800
#define DISH_RPT_SPACE 6200
#define DISH_TOP_BIT 0x8000
#define PANASONIC_HDR_MARK 3502
#define PANASONIC_HDR_SPACE 1750
#define PANASONIC_BIT_MARK 502
#define PANASONIC_ONE_SPACE 1244
#define PANASONIC_ZERO_SPACE 400
#define JVC_HDR_MARK 8000
#define JVC_HDR_SPACE 4000
#define JVC_BIT_MARK 600
#define JVC_ONE_SPACE 1600
#define JVC_ZERO_SPACE 550
#define JVC_RPT_LENGTH 60000
#define SHARP_BITS 15
#define DISH_BITS 16
#define TOLERANCE 25 // percent tolerance in measurements
#define LTOL (1.0 - TOLERANCE/100.)
#define UTOL (1.0 + TOLERANCE/100.)
#define _GAP 5000 // Minimum map between transmissions
#define GAP_TICKS (_GAP/USECPERTICK)
#define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK))
#define TICKS_HIGH(us) (int) (((us)*UTOL/USECPERTICK + 1))
#ifndef DEBUG
int MATCH(int measured, int desired) {return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired);}
int MATCH_MARK(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us + MARK_EXCESS));}
int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us - MARK_EXCESS));}
// Debugging versions are in IRremote.cpp
#endif
// receiver states
#define STATE_IDLE 2
#define STATE_MARK 3
#define STATE_SPACE 4
#define STATE_STOP 5
// information for the interrupt handler
typedef struct {
uint8_t recvpin; // pin for IR data from detector
uint8_t rcvstate; // state machine
uint8_t blinkflag; // TRUE to enable blinking of pin 13 on IR processing
unsigned int timer; // state timer, counts 50uS ticks.
unsigned int rawbuf[RAWBUF]; // raw data
uint8_t rawlen; // counter of entries in rawbuf
}
irparams_t;
// Defined in IRremote.cpp
extern volatile irparams_t irparams;
// IR detector output is active low
#define MARK 0
#define SPACE 1
#define TOPBIT 0x80000000
#define NEC_BITS 32
#define SONY_BITS 12
#define SANYO_BITS 12
#define MITSUBISHI_BITS 16
#define MIN_RC5_SAMPLES 11
#define MIN_RC6_SAMPLES 1
#define PANASONIC_BITS 48
#define JVC_BITS 16
// defines for timer2 (8 bits)
#if defined(IR_USE_TIMER2)
#define TIMER_RESET
#define TIMER_ENABLE_PWM (TCCR2A |= _BV(COM2B1))
#define TIMER_DISABLE_PWM (TCCR2A &= ~(_BV(COM2B1)))
#define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A))
#define TIMER_DISABLE_INTR (TIMSK2 = 0)
#define TIMER_INTR_NAME TIMER2_COMPA_vect
#define TIMER_CONFIG_KHZ(val) ({ \
const uint8_t pwmval = SYSCLOCK / 2000 / (val); \
TCCR2A = _BV(WGM20); \
TCCR2B = _BV(WGM22) | _BV(CS20); \
OCR2A = pwmval; \
OCR2B = pwmval / 3; \
})
#define TIMER_COUNT_TOP (SYSCLOCK * USECPERTICK / 1000000)
#if (TIMER_COUNT_TOP < 256)
#define TIMER_CONFIG_NORMAL() ({ \
TCCR2A = _BV(WGM21); \
TCCR2B = _BV(CS20); \
OCR2A = TIMER_COUNT_TOP; \
TCNT2 = 0; \
})
#else
#define TIMER_CONFIG_NORMAL() ({ \
TCCR2A = _BV(WGM21); \
TCCR2B = _BV(CS21); \
OCR2A = TIMER_COUNT_TOP / 8; \
TCNT2 = 0; \
})
#endif
#if defined(CORE_OC2B_PIN)
#define TIMER_PWM_PIN CORE_OC2B_PIN /* Teensy */
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define TIMER_PWM_PIN 9 /* Arduino Mega */
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
#define TIMER_PWM_PIN 14 /* Sanguino */
#else
#define TIMER_PWM_PIN 3 /* Arduino Duemilanove, Diecimila, LilyPad, etc */
#endif
// defines for timer1 (16 bits)
#elif defined(IR_USE_TIMER1)
#define TIMER_RESET
#define TIMER_ENABLE_PWM (TCCR1A |= _BV(COM1A1))
#define TIMER_DISABLE_PWM (TCCR1A &= ~(_BV(COM1A1)))
#if defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__)
#define TIMER_ENABLE_INTR (TIMSK = _BV(OCIE1A))
#define TIMER_DISABLE_INTR (TIMSK = 0)
#else
#define TIMER_ENABLE_INTR (TIMSK1 = _BV(OCIE1A))
#define TIMER_DISABLE_INTR (TIMSK1 = 0)
#endif
#if defined(__AVR_ATtinyX4__)
#define TIMER_INTR_NAME TIM1_COMPA_vect
#else
#define TIMER_INTR_NAME TIMER1_COMPA_vect
#endif
#define TIMER_CONFIG_KHZ(val) ({ \
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
TCCR1A = _BV(WGM11); \
TCCR1B = _BV(WGM13) | _BV(CS10); \
ICR1 = pwmval; \
OCR1A = pwmval / 3; \
})
#define TIMER_CONFIG_NORMAL() ({ \
TCCR1A = 0; \
TCCR1B = _BV(WGM12) | _BV(CS10); \
OCR1A = SYSCLOCK * USECPERTICK / 1000000; \
TCNT1 = 0; \
})
#if defined(CORE_OC1A_PIN)
#define TIMER_PWM_PIN CORE_OC1A_PIN /* Teensy */
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define TIMER_PWM_PIN 11 /* Arduino Mega */
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
#define TIMER_PWM_PIN 13 /* Sanguino */
#elif defined(__AVR_ATtinyX4__)
#define TIMER_PWM_PIN 6 /* ATTiny84 */
#else
#define TIMER_PWM_PIN 9 /* Arduino Duemilanove, Diecimila, LilyPad, etc */
#endif
// defines for timer3 (16 bits)
#elif defined(IR_USE_TIMER3)
#define TIMER_RESET
#define TIMER_ENABLE_PWM (TCCR3A |= _BV(COM3A1))
#define TIMER_DISABLE_PWM (TCCR3A &= ~(_BV(COM3A1)))
#define TIMER_ENABLE_INTR (TIMSK3 = _BV(OCIE3A))
#define TIMER_DISABLE_INTR (TIMSK3 = 0)
#define TIMER_INTR_NAME TIMER3_COMPA_vect
#define TIMER_CONFIG_KHZ(val) ({ \
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
TCCR3A = _BV(WGM31); \
TCCR3B = _BV(WGM33) | _BV(CS30); \
ICR3 = pwmval; \
OCR3A = pwmval / 3; \
})
#define TIMER_CONFIG_NORMAL() ({ \
TCCR3A = 0; \
TCCR3B = _BV(WGM32) | _BV(CS30); \
OCR3A = SYSCLOCK * USECPERTICK / 1000000; \
TCNT3 = 0; \
})
#if defined(CORE_OC3A_PIN)
#define TIMER_PWM_PIN CORE_OC3A_PIN /* Teensy */
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define TIMER_PWM_PIN 5 /* Arduino Mega */
#else
#error "Please add OC3A pin number here\n"
#endif
// defines for timer4 (10 bits, high speed option)
#elif defined(IR_USE_TIMER4_HS)
#define TIMER_RESET
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4))
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
#define TIMER_INTR_NAME TIMER4_OVF_vect
#define TIMER_CONFIG_KHZ(val) ({ \
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
TCCR4A = (1<<PWM4A); \
TCCR4B = _BV(CS40); \
TCCR4C = 0; \
TCCR4D = (1<<WGM40); \
TCCR4E = 0; \
TC4H = pwmval >> 8; \
OCR4C = pwmval; \
TC4H = (pwmval / 3) >> 8; \
OCR4A = (pwmval / 3) & 255; \
})
#define TIMER_CONFIG_NORMAL() ({ \
TCCR4A = 0; \
TCCR4B = _BV(CS40); \
TCCR4C = 0; \
TCCR4D = 0; \
TCCR4E = 0; \
TC4H = (SYSCLOCK * USECPERTICK / 1000000) >> 8; \
OCR4C = (SYSCLOCK * USECPERTICK / 1000000) & 255; \
TC4H = 0; \
TCNT4 = 0; \
})
#if defined(CORE_OC4A_PIN)
#define TIMER_PWM_PIN CORE_OC4A_PIN /* Teensy */
#elif defined(__AVR_ATmega32U4__)
#define TIMER_PWM_PIN 13 /* Leonardo */
#else
#error "Please add OC4A pin number here\n"
#endif
// defines for timer4 (16 bits)
#elif defined(IR_USE_TIMER4)
#define TIMER_RESET
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(OCIE4A))
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
#define TIMER_INTR_NAME TIMER4_COMPA_vect
#define TIMER_CONFIG_KHZ(val) ({ \
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
TCCR4A = _BV(WGM41); \
TCCR4B = _BV(WGM43) | _BV(CS40); \
ICR4 = pwmval; \
OCR4A = pwmval / 3; \
})
#define TIMER_CONFIG_NORMAL() ({ \
TCCR4A = 0; \
TCCR4B = _BV(WGM42) | _BV(CS40); \
OCR4A = SYSCLOCK * USECPERTICK / 1000000; \
TCNT4 = 0; \
})
#if defined(CORE_OC4A_PIN)
#define TIMER_PWM_PIN CORE_OC4A_PIN
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define TIMER_PWM_PIN 6 /* Arduino Mega */
#else
#error "Please add OC4A pin number here\n"
#endif
// defines for timer5 (16 bits)
#elif defined(IR_USE_TIMER5)
#define TIMER_RESET
#define TIMER_ENABLE_PWM (TCCR5A |= _BV(COM5A1))
#define TIMER_DISABLE_PWM (TCCR5A &= ~(_BV(COM5A1)))
#define TIMER_ENABLE_INTR (TIMSK5 = _BV(OCIE5A))
#define TIMER_DISABLE_INTR (TIMSK5 = 0)
#define TIMER_INTR_NAME TIMER5_COMPA_vect
#define TIMER_CONFIG_KHZ(val) ({ \
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
TCCR5A = _BV(WGM51); \
TCCR5B = _BV(WGM53) | _BV(CS50); \
ICR5 = pwmval; \
OCR5A = pwmval / 3; \
})
#define TIMER_CONFIG_NORMAL() ({ \
TCCR5A = 0; \
TCCR5B = _BV(WGM52) | _BV(CS50); \
OCR5A = SYSCLOCK * USECPERTICK / 1000000; \
TCNT5 = 0; \
})
#if defined(CORE_OC5A_PIN)
#define TIMER_PWM_PIN CORE_OC5A_PIN
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define TIMER_PWM_PIN 46 /* Arduino Mega */
#else
#error "Please add OC5A pin number here\n"
#endif
#else // unknown timer
#error "Internal code configuration error, no known IR_USE_TIMER# defined\n"
#endif
// defines for blinking the LED
#if defined(CORE_LED0_PIN)
#define BLINKLED CORE_LED0_PIN
#define BLINKLED_ON() (digitalWrite(CORE_LED0_PIN, HIGH))
#define BLINKLED_OFF() (digitalWrite(CORE_LED0_PIN, LOW))
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define BLINKLED 13
#define BLINKLED_ON() (PORTB |= B10000000)
#define BLINKLED_OFF() (PORTB &= B01111111)
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
#define BLINKLED 0
#define BLINKLED_ON() (PORTD |= B00000001)
#define BLINKLED_OFF() (PORTD &= B11111110)
#else
#define BLINKLED 13
#define BLINKLED_ON() (PORTB |= B00100000)
#define BLINKLED_OFF() (PORTB &= B11011111)
#endif
#endif

View File

@@ -0,0 +1,458 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

View File

@@ -0,0 +1,167 @@
/*
* IRrecord: record and play back IR signals as a minimal
* An IR detector/demodulator must be connected to the input RECV_PIN.
* An IR LED must be connected to the output PWM pin 3.
* A button must be connected to the input BUTTON_PIN; this is the
* send button.
* A visible LED can be connected to STATUS_PIN to provide status.
*
* The logic is:
* If the button is pressed, send the IR code.
* If an IR code is received, record it.
*
* Version 0.11 September, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
int RECV_PIN = 11;
int BUTTON_PIN = 12;
int STATUS_PIN = 13;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(BUTTON_PIN, INPUT);
pinMode(STATUS_PIN, OUTPUT);
}
// Storage for the recorded code
int codeType = -1; // The type of code
unsigned long codeValue; // The code value if not raw
unsigned int rawCodes[RAWBUF]; // The durations if raw
int codeLen; // The length of the code
int toggle = 0; // The RC5/6 toggle state
// Stores the code for later playback
// Most of this code is just logging
void storeCode(decode_results *results) {
codeType = results->decode_type;
int count = results->rawlen;
if (codeType == UNKNOWN) {
Serial.println("Received unknown code, saving as raw");
codeLen = results->rawlen - 1;
// To store raw codes:
// Drop first value (gap)
// Convert from ticks to microseconds
// Tweak marks shorter, and spaces longer to cancel out IR receiver distortion
for (int i = 1; i <= codeLen; i++) {
if (i % 2) {
// Mark
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
Serial.print(" m");
}
else {
// Space
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
Serial.print(" s");
}
Serial.print(rawCodes[i - 1], DEC);
}
Serial.println("");
}
else {
if (codeType == NEC) {
Serial.print("Received NEC: ");
if (results->value == REPEAT) {
// Don't record a NEC repeat value as that's useless.
Serial.println("repeat; ignoring.");
return;
}
}
else if (codeType == SONY) {
Serial.print("Received SONY: ");
}
else if (codeType == RC5) {
Serial.print("Received RC5: ");
}
else if (codeType == RC6) {
Serial.print("Received RC6: ");
}
else {
Serial.print("Unexpected codeType ");
Serial.print(codeType, DEC);
Serial.println("");
}
Serial.println(results->value, HEX);
codeValue = results->value;
codeLen = results->bits;
}
}
void sendCode(int repeat) {
if (codeType == NEC) {
if (repeat) {
irsend.sendNEC(REPEAT, codeLen);
Serial.println("Sent NEC repeat");
}
else {
irsend.sendNEC(codeValue, codeLen);
Serial.print("Sent NEC ");
Serial.println(codeValue, HEX);
}
}
else if (codeType == SONY) {
irsend.sendSony(codeValue, codeLen);
Serial.print("Sent Sony ");
Serial.println(codeValue, HEX);
}
else if (codeType == RC5 || codeType == RC6) {
if (!repeat) {
// Flip the toggle bit for a new button press
toggle = 1 - toggle;
}
// Put the toggle bit into the code to send
codeValue = codeValue & ~(1 << (codeLen - 1));
codeValue = codeValue | (toggle << (codeLen - 1));
if (codeType == RC5) {
Serial.print("Sent RC5 ");
Serial.println(codeValue, HEX);
irsend.sendRC5(codeValue, codeLen);
}
else {
irsend.sendRC6(codeValue, codeLen);
Serial.print("Sent RC6 ");
Serial.println(codeValue, HEX);
}
}
else if (codeType == UNKNOWN /* i.e. raw */) {
// Assume 38 KHz
irsend.sendRaw(rawCodes, codeLen, 38);
Serial.println("Sent raw");
}
}
int lastButtonState;
void loop() {
// If button pressed, send the code.
int buttonState = digitalRead(BUTTON_PIN);
if (lastButtonState == HIGH && buttonState == LOW) {
Serial.println("Released");
irrecv.enableIRIn(); // Re-enable receiver
}
if (buttonState) {
Serial.println("Pressed, sending");
digitalWrite(STATUS_PIN, HIGH);
sendCode(lastButtonState == buttonState);
digitalWrite(STATUS_PIN, LOW);
delay(50); // Wait a bit between retransmissions
}
else if (irrecv.decode(&results)) {
digitalWrite(STATUS_PIN, HIGH);
storeCode(&results);
irrecv.resume(); // resume receiver
digitalWrite(STATUS_PIN, LOW);
}
lastButtonState = buttonState;
}

View File

@@ -0,0 +1,28 @@
/*
* 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
*/
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}

View File

@@ -0,0 +1,81 @@
/*
* IRremote: IRrecvDump - dump details of 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
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
*/
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
// 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 *)v
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.print("Unknown encoding: ");
}
else if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
else if (results->decode_type == PANASONIC) {
Serial.print("Decoded PANASONIC - Address: ");
Serial.print(results->panasonicAddress,HEX);
Serial.print(" Value: ");
}
else if (results->decode_type == JVC) {
Serial.print("Decoded JVC: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
Serial.print("Raw (");
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 loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
dump(&results);
irrecv.resume(); // Receive the next value
}
}

View File

@@ -0,0 +1,85 @@
/*
* 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
*/
#include <IRremote.h>
int RECV_PIN = 11;
int RELAY_PIN = 4;
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 *)v
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.println("Could not decode message");
}
else {
if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
}
Serial.print("Raw (");
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(RELAY_PIN, 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
// IR received, toggle the relay
if (millis() - last > 250) {
on = !on;
digitalWrite(RELAY_PIN, on ? HIGH : LOW);
digitalWrite(13, on ? HIGH : LOW);
dump(&results);
}
last = millis();
irrecv.resume(); // Receive the next value
}
}

View File

@@ -0,0 +1,25 @@
/*
* IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
* An IR LED must be connected to Arduino PWM pin 3.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
IRsend irsend;
void setup()
{
Serial.begin(9600);
}
void loop() {
if (Serial.read() != -1) {
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(40);
}
}
}

View File

@@ -0,0 +1,190 @@
/*
* IRremote: IRtest unittest
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*
* Note: to run these tests, edit IRremote/IRremote.h to add "#define TEST"
* You must then recompile the library by removing IRremote.o and restarting
* the arduino IDE.
*/
#include <IRremote.h>
#include <IRremoteInt.h>
// 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 *)v
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.println("Could not decode message");
}
else {
if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
}
Serial.print("Raw (");
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("");
}
IRrecv irrecv(0);
decode_results results;
class IRsendDummy :
public IRsend
{
public:
// For testing, just log the marks/spaces
#define SENDLOG_LEN 128
int sendlog[SENDLOG_LEN];
int sendlogcnt;
IRsendDummy() :
IRsend() {
}
void reset() {
sendlogcnt = 0;
}
void mark(int time) {
sendlog[sendlogcnt] = time;
if (sendlogcnt < SENDLOG_LEN) sendlogcnt++;
}
void space(int time) {
sendlog[sendlogcnt] = -time;
if (sendlogcnt < SENDLOG_LEN) sendlogcnt++;
}
// Copies the dummy buf into the interrupt buf
void useDummyBuf() {
int last = SPACE;
irparams.rcvstate = STATE_STOP;
irparams.rawlen = 1; // Skip the gap
for (int i = 0 ; i < sendlogcnt; i++) {
if (sendlog[i] < 0) {
if (last == MARK) {
// New space
irparams.rawbuf[irparams.rawlen++] = (-sendlog[i] - MARK_EXCESS) / USECPERTICK;
last = SPACE;
}
else {
// More space
irparams.rawbuf[irparams.rawlen - 1] += -sendlog[i] / USECPERTICK;
}
}
else if (sendlog[i] > 0) {
if (last == SPACE) {
// New mark
irparams.rawbuf[irparams.rawlen++] = (sendlog[i] + MARK_EXCESS) / USECPERTICK;
last = MARK;
}
else {
// More mark
irparams.rawbuf[irparams.rawlen - 1] += sendlog[i] / USECPERTICK;
}
}
}
if (irparams.rawlen % 2) {
irparams.rawlen--; // Remove trailing space
}
}
};
IRsendDummy irsenddummy;
void verify(unsigned long val, int bits, int type) {
irsenddummy.useDummyBuf();
irrecv.decode(&results);
Serial.print("Testing ");
Serial.print(val, HEX);
if (results.value == val && results.bits == bits && results.decode_type == type) {
Serial.println(": OK");
}
else {
Serial.println(": Error");
dump(&results);
}
}
void testNEC(unsigned long val, int bits) {
irsenddummy.reset();
irsenddummy.sendNEC(val, bits);
verify(val, bits, NEC);
}
void testSony(unsigned long val, int bits) {
irsenddummy.reset();
irsenddummy.sendSony(val, bits);
verify(val, bits, SONY);
}
void testRC5(unsigned long val, int bits) {
irsenddummy.reset();
irsenddummy.sendRC5(val, bits);
verify(val, bits, RC5);
}
void testRC6(unsigned long val, int bits) {
irsenddummy.reset();
irsenddummy.sendRC6(val, bits);
verify(val, bits, RC6);
}
void test() {
Serial.println("NEC tests");
testNEC(0x00000000, 32);
testNEC(0xffffffff, 32);
testNEC(0xaaaaaaaa, 32);
testNEC(0x55555555, 32);
testNEC(0x12345678, 32);
Serial.println("Sony tests");
testSony(0xfff, 12);
testSony(0x000, 12);
testSony(0xaaa, 12);
testSony(0x555, 12);
testSony(0x123, 12);
Serial.println("RC5 tests");
testRC5(0xfff, 12);
testRC5(0x000, 12);
testRC5(0xaaa, 12);
testRC5(0x555, 12);
testRC5(0x123, 12);
Serial.println("RC6 tests");
testRC6(0xfffff, 20);
testRC6(0x00000, 20);
testRC6(0xaaaaa, 20);
testRC6(0x55555, 20);
testRC6(0x12345, 20);
}
void setup()
{
Serial.begin(9600);
test();
}
void loop() {
}

View File

@@ -0,0 +1,290 @@
/*
* Test send/receive functions of IRremote, using a pair of Arduinos.
*
* Arduino #1 should have an IR LED connected to the send pin (3).
* Arduino #2 should have an IR detector/demodulator connected to the
* receive pin (11) and a visible LED connected to pin 3.
*
* The cycle:
* Arduino #1 will wait 2 seconds, then run through the tests.
* It repeats this forever.
* Arduino #2 will wait for at least one second of no signal
* (to synchronize with #1). It will then wait for the same test
* signals. It will log all the status to the serial port. It will
* also indicate status through the LED, which will flash each time a test
* is completed. If there is an error, it will light up for 5 seconds.
*
* The test passes if the LED flashes 19 times, pauses, and then repeats.
* The test fails if the LED lights for 5 seconds.
*
* The test software automatically decides which board is the sender and which is
* the receiver by looking for an input on the send pin, which will indicate
* the sender. You should hook the serial port to the receiver for debugging.
*
* Copyright 2010 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
int RECV_PIN = 11;
int LED_PIN = 3;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;
#define RECEIVER 1
#define SENDER 2
#define ERROR 3
int mode;
void setup()
{
Serial.begin(9600);
// Check RECV_PIN to decide if we're RECEIVER or SENDER
if (digitalRead(RECV_PIN) == HIGH) {
mode = RECEIVER;
irrecv.enableIRIn();
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
Serial.println("Receiver mode");
}
else {
mode = SENDER;
Serial.println("Sender mode");
}
}
// Wait for the gap between tests, to synchronize with
// the sender.
// Specifically, wait for a signal followed by a gap of at last gap ms.
void waitForGap(int gap) {
Serial.println("Waiting for gap");
while (1) {
while (digitalRead(RECV_PIN) == LOW) {
}
unsigned long time = millis();
while (digitalRead(RECV_PIN) == HIGH) {
if (millis() - time > gap) {
return;
}
}
}
}
// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.println("Could not decode message");
}
else {
if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
}
Serial.print("Raw (");
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("");
}
// Test send or receive.
// If mode is SENDER, send a code of the specified type, value, and bits
// If mode is RECEIVER, receive a code and verify that it is of the
// specified type, value, and bits. For success, the LED is flashed;
// for failure, the mode is set to ERROR.
// The motivation behind this method is that the sender and the receiver
// can do the same test calls, and the mode variable indicates whether
// to send or receive.
void test(char *label, int type, unsigned long value, int bits) {
if (mode == SENDER) {
Serial.println(label);
if (type == NEC) {
irsend.sendNEC(value, bits);
}
else if (type == SONY) {
irsend.sendSony(value, bits);
}
else if (type == RC5) {
irsend.sendRC5(value, bits);
}
else if (type == RC6) {
irsend.sendRC6(value, bits);
}
else {
Serial.print(label);
Serial.println("Bad type!");
}
delay(200);
}
else if (mode == RECEIVER) {
irrecv.resume(); // Receive the next value
unsigned long max_time = millis() + 30000;
Serial.print(label);
// Wait for decode or timeout
while (!irrecv.decode(&results)) {
if (millis() > max_time) {
Serial.println("Timeout receiving data");
mode = ERROR;
return;
}
}
if (type == results.decode_type && value == results.value && bits == results.bits) {
Serial.println (": OK");
digitalWrite(LED_PIN, HIGH);
delay(20);
digitalWrite(LED_PIN, LOW);
}
else {
Serial.println(": BAD");
dump(&results);
mode = ERROR;
}
}
}
// Test raw send or receive. This is similar to the test method,
// except it send/receives raw data.
void testRaw(char *label, unsigned int *rawbuf, int rawlen) {
if (mode == SENDER) {
Serial.println(label);
irsend.sendRaw(rawbuf, rawlen, 38 /* kHz */);
delay(200);
}
else if (mode == RECEIVER ) {
irrecv.resume(); // Receive the next value
unsigned long max_time = millis() + 30000;
Serial.print(label);
// Wait for decode or timeout
while (!irrecv.decode(&results)) {
if (millis() > max_time) {
Serial.println("Timeout receiving data");
mode = ERROR;
return;
}
}
// Received length has extra first element for gap
if (rawlen != results.rawlen - 1) {
Serial.print("Bad raw length ");
Serial.println(results.rawlen, DEC);
mode = ERROR;
return;
}
for (int i = 0; i < rawlen; i++) {
long got = results.rawbuf[i+1] * USECPERTICK;
// Adjust for extra duration of marks
if (i % 2 == 0) {
got -= MARK_EXCESS;
}
else {
got += MARK_EXCESS;
}
// See if close enough, within 25%
if (rawbuf[i] * 1.25 < got || got * 1.25 < rawbuf[i]) {
Serial.println(": BAD");
dump(&results);
mode = ERROR;
return;
}
}
Serial.println (": OK");
digitalWrite(LED_PIN, HIGH);
delay(20);
digitalWrite(LED_PIN, LOW);
}
}
// This is the raw data corresponding to NEC 0x12345678
unsigned int sendbuf[] = { /* NEC format */
9000, 4500,
560, 560, 560, 560, 560, 560, 560, 1690, /* 1 */
560, 560, 560, 560, 560, 1690, 560, 560, /* 2 */
560, 560, 560, 560, 560, 1690, 560, 1690, /* 3 */
560, 560, 560, 1690, 560, 560, 560, 560, /* 4 */
560, 560, 560, 1690, 560, 560, 560, 1690, /* 5 */
560, 560, 560, 1690, 560, 1690, 560, 560, /* 6 */
560, 560, 560, 1690, 560, 1690, 560, 1690, /* 7 */
560, 1690, 560, 560, 560, 560, 560, 560, /* 8 */
560};
void loop() {
if (mode == SENDER) {
delay(2000); // Delay for more than gap to give receiver a better chance to sync.
}
else if (mode == RECEIVER) {
waitForGap(1000);
}
else if (mode == ERROR) {
// Light up for 5 seconds for error
digitalWrite(LED_PIN, HIGH);
delay(5000);
digitalWrite(LED_PIN, LOW);
mode = RECEIVER; // Try again
return;
}
// The test suite.
test("SONY1", SONY, 0x123, 12);
test("SONY2", SONY, 0x000, 12);
test("SONY3", SONY, 0xfff, 12);
test("SONY4", SONY, 0x12345, 20);
test("SONY5", SONY, 0x00000, 20);
test("SONY6", SONY, 0xfffff, 20);
test("NEC1", NEC, 0x12345678, 32);
test("NEC2", NEC, 0x00000000, 32);
test("NEC3", NEC, 0xffffffff, 32);
test("NEC4", NEC, REPEAT, 32);
test("RC51", RC5, 0x12345678, 32);
test("RC52", RC5, 0x0, 32);
test("RC53", RC5, 0xffffffff, 32);
test("RC61", RC6, 0x12345678, 32);
test("RC62", RC6, 0x0, 32);
test("RC63", RC6, 0xffffffff, 32);
// Tests of raw sending and receiving.
// First test sending raw and receiving raw.
// Then test sending raw and receiving decoded NEC
// Then test sending NEC and receiving raw
testRaw("RAW1", sendbuf, 67);
if (mode == SENDER) {
testRaw("RAW2", sendbuf, 67);
test("RAW3", NEC, 0x12345678, 32);
}
else {
test("RAW2", NEC, 0x12345678, 32);
testRaw("RAW3", sendbuf, 67);
}
}

View File

@@ -0,0 +1,29 @@
/*
* IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
* An IR LED must be connected to Arduino PWM pin 3.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
*/
#include <IRremote.h>
#define PanasonicAddress 0x4004 // Panasonic address (Pre data)
#define PanasonicPower 0x100BCBD // Panasonic Power button
#define JVCPower 0xC5E8
IRsend irsend;
void setup()
{
}
void loop() {
irsend.sendPanasonic(PanasonicAddress,PanasonicPower); // This should turn your TV on and off
irsend.sendJVC(JVCPower, 16,0); // hex value, 16 bits, no repeat
delayMicroseconds(50); // see http://www.sbprojects.com/knowledge/ir/jvc.php for information
irsend.sendJVC(JVCPower, 16,1); // hex value, 16 bits, repeat
delayMicroseconds(50);
}

View File

@@ -0,0 +1,50 @@
#######################################
# Syntax Coloring Map For IRremote
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
decode_results KEYWORD1
IRrecv KEYWORD1
IRsend KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
blink13 KEYWORD2
decode KEYWORD2
enableIRIn KEYWORD2
resume KEYWORD2
enableIROut KEYWORD2
sendNEC KEYWORD2
sendSony KEYWORD2
sendSanyo KEYWORD2
sendMitsubishi KEYWORD2
sendRaw KEYWORD2
sendRC5 KEYWORD2
sendRC6 KEYWORD2
sendDISH KEYWORD2
sendSharp KEYWORD2
sendPanasonic KEYWORD2
sendJVC KEYWORD2
#
#######################################
# Constants (LITERAL1)
#######################################
NEC LITERAL1
SONY LITERAL1
SANYO LITERAL1
MITSUBISHI LITERAL1
RC5 LITERAL1
RC6 LITERAL1
DISH LITERAL1
SHARP LITERAL1
PANASONIC LITERAL1
JVC LITERAL1
UNKNOWN LITERAL1
REPEAT LITERAL1

View File

@@ -0,0 +1,14 @@
This is the IRremote library for the Arduino.
To download from github (http://github.com/shirriff/Arduino-IRremote), click on the "Downloads" link in the upper right, click "Download as zip", and get a zip file. Unzip it and rename the directory shirriff-Arduino-IRremote-nnn to IRremote
To install, move the downloaded IRremote directory to:
arduino-1.x/libraries/IRremote
where arduino-1.x is your Arduino installation directory
After installation you should have files such as:
arduino-1.x/libraries/IRremote/IRremote.cpp
For details on the library see the Wiki on github or the blog post http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
Copyright 2009-2012 Ken Shirriff

Binary file not shown.

View File

@@ -0,0 +1,206 @@
/*
MsTimer2.h - Using timer2 with 1ms resolution
Javier Valencia <javiervalencia80@gmail.com>
History:
29/Dec/11 - V0.6 added support for ATmega32u4, AT90USB646, AT90USB1286 (paul@pjrc.com)
some improvements added by Bill Perry
note: uses timer4 on Atmega32u4
29/May/09 - V0.5 added support for Atmega1280 (thanks to Manuel Negri)
19/Mar/09 - V0.4 added support for ATmega328P (thanks to Jerome Despatis)
11/Jun/08 - V0.3
changes to allow working with different CPU frequencies
added support for ATMega128 (using timer2)
compatible with ATMega48/88/168/8
10/May/08 - V0.2 added some security tests and volatile keywords
9/May/08 - V0.1 released working on ATMEGA168 only
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <MsTimer2.h>
unsigned long MsTimer2::msecs;
void (*MsTimer2::func)();
volatile unsigned long MsTimer2::count;
volatile char MsTimer2::overflowing;
volatile unsigned int MsTimer2::tcnt2;
void MsTimer2::set(unsigned long ms, void (*f)()) {
float prescaler = 0.0;
if (ms == 0)
msecs = 1;
else
msecs = ms;
func = f;
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
TIMSK2 &= ~(1<<TOIE2);
TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
TCCR2B &= ~(1<<WGM22);
ASSR &= ~(1<<AS2);
TIMSK2 &= ~(1<<OCIE2A);
if ((F_CPU >= 1000000UL) && (F_CPU <= 16000000UL)) { // prescaler set to 64
TCCR2B |= (1<<CS22);
TCCR2B &= ~((1<<CS21) | (1<<CS20));
prescaler = 64.0;
} else if (F_CPU < 1000000UL) { // prescaler set to 8
TCCR2B |= (1<<CS21);
TCCR2B &= ~((1<<CS22) | (1<<CS20));
prescaler = 8.0;
} else { // F_CPU > 16Mhz, prescaler set to 128
TCCR2B |= ((1<<CS22) | (1<<CS20));
TCCR2B &= ~(1<<CS21);
prescaler = 128.0;
}
#elif defined (__AVR_ATmega8__)
TIMSK &= ~(1<<TOIE2);
TCCR2 &= ~((1<<WGM21) | (1<<WGM20));
TIMSK &= ~(1<<OCIE2);
ASSR &= ~(1<<AS2);
if ((F_CPU >= 1000000UL) && (F_CPU <= 16000000UL)) { // prescaler set to 64
TCCR2 |= (1<<CS22);
TCCR2 &= ~((1<<CS21) | (1<<CS20));
prescaler = 64.0;
} else if (F_CPU < 1000000UL) { // prescaler set to 8
TCCR2 |= (1<<CS21);
TCCR2 &= ~((1<<CS22) | (1<<CS20));
prescaler = 8.0;
} else { // F_CPU > 16Mhz, prescaler set to 128
TCCR2 |= ((1<<CS22) && (1<<CS20));
TCCR2 &= ~(1<<CS21);
prescaler = 128.0;
}
#elif defined (__AVR_ATmega128__)
TIMSK &= ~(1<<TOIE2);
TCCR2 &= ~((1<<WGM21) | (1<<WGM20));
TIMSK &= ~(1<<OCIE2);
if ((F_CPU >= 1000000UL) && (F_CPU <= 16000000UL)) { // prescaler set to 64
TCCR2 |= ((1<<CS21) | (1<<CS20));
TCCR2 &= ~(1<<CS22);
prescaler = 64.0;
} else if (F_CPU < 1000000UL) { // prescaler set to 8
TCCR2 |= (1<<CS21);
TCCR2 &= ~((1<<CS22) | (1<<CS20));
prescaler = 8.0;
} else { // F_CPU > 16Mhz, prescaler set to 256
TCCR2 |= (1<<CS22);
TCCR2 &= ~((1<<CS21) | (1<<CS20));
prescaler = 256.0;
}
#elif defined (__AVR_ATmega32U4__)
TCCR4B = 0;
TCCR4A = 0;
TCCR4C = 0;
TCCR4D = 0;
TCCR4E = 0;
if (F_CPU >= 16000000L) {
TCCR4B = (1<<CS43) | (1<<PSR4);
prescaler = 128.0;
} else if (F_CPU >= 8000000L) {
TCCR4B = (1<<CS42) | (1<<CS41) | (1<<CS40) | (1<<PSR4);
prescaler = 64.0;
} else if (F_CPU >= 4000000L) {
TCCR4B = (1<<CS42) | (1<<CS41) | (1<<PSR4);
prescaler = 32.0;
} else if (F_CPU >= 2000000L) {
TCCR4B = (1<<CS42) | (1<<CS40) | (1<<PSR4);
prescaler = 16.0;
} else if (F_CPU >= 1000000L) {
TCCR4B = (1<<CS42) | (1<<PSR4);
prescaler = 8.0;
} else if (F_CPU >= 500000L) {
TCCR4B = (1<<CS41) | (1<<CS40) | (1<<PSR4);
prescaler = 4.0;
} else {
TCCR4B = (1<<CS41) | (1<<PSR4);
prescaler = 2.0;
}
tcnt2 = (int)((float)F_CPU * 0.001 / prescaler) - 1;
OCR4C = tcnt2;
return;
#else
#error Unsupported CPU type
#endif
tcnt2 = 256 - (int)((float)F_CPU * 0.001 / prescaler);
}
void MsTimer2::start() {
count = 0;
overflowing = 0;
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || defined (__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
TCNT2 = tcnt2;
TIMSK2 |= (1<<TOIE2);
#elif defined (__AVR_ATmega128__)
TCNT2 = tcnt2;
TIMSK |= (1<<TOIE2);
#elif defined (__AVR_ATmega8__)
TCNT2 = tcnt2;
TIMSK |= (1<<TOIE2);
#elif defined (__AVR_ATmega32U4__)
TIFR4 = (1<<TOV4);
TCNT4 = 0;
TIMSK4 = (1<<TOIE4);
#endif
}
void MsTimer2::stop() {
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || defined (__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
TIMSK2 &= ~(1<<TOIE2);
#elif defined (__AVR_ATmega128__)
TIMSK &= ~(1<<TOIE2);
#elif defined (__AVR_ATmega8__)
TIMSK &= ~(1<<TOIE2);
#elif defined (__AVR_ATmega32U4__)
TIMSK4 = 0;
#endif
}
void MsTimer2::_overflow() {
count += 1;
if (count >= msecs && !overflowing) {
overflowing = 1;
count = count - msecs; // subtract ms to catch missed overflows
// set to 0 if you don't want this.
(*func)();
overflowing = 0;
}
}
#if defined (__AVR_ATmega32U4__)
ISR(TIMER4_OVF_vect) {
#else
ISR(TIMER2_OVF_vect) {
#endif
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || defined (__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
TCNT2 = MsTimer2::tcnt2;
#elif defined (__AVR_ATmega128__)
TCNT2 = MsTimer2::tcnt2;
#elif defined (__AVR_ATmega8__)
TCNT2 = MsTimer2::tcnt2;
#elif defined (__AVR_ATmega32U4__)
// not necessary on 32u4's high speed timer4
#endif
MsTimer2::_overflow();
}

View File

@@ -0,0 +1,23 @@
#ifndef MsTimer2_h
#define MsTimer2_h
#ifdef __AVR__
#include <avr/interrupt.h>
#else
#error MsTimer2 library only works on AVR architecture
#endif
namespace MsTimer2 {
extern unsigned long msecs;
extern void (*func)();
extern volatile unsigned long count;
extern volatile char overflowing;
extern volatile unsigned int tcnt2;
void set(unsigned long ms, void (*f)());
void start();
void stop();
void _overflow();
}
#endif

View File

@@ -0,0 +1,42 @@
char dummyvar; // to get Arduinoi IDE to include core headers properly
/*
MsTimer2 is a small and very easy to use library to interface Timer2 with
humans. It's called MsTimer2 because it "hardcodes" a resolution of 1
millisecond on timer2
For Details see: http://www.arduino.cc/playground/Main/MsTimer2
*/
#include <MsTimer2.h>
// Switch on LED on and off each half second
#if defined(ARDUINO) && ARDUINO >= 100
const int led_pin = LED_BUILTIN; // 1.0 built in LED pin var
#else
#if defined(CORE_LED0_PIN)
const int led_pin = CORE_LED0_PIN; // 3rd party LED pin define
#else
const int led_pin = 13; // default to pin 13
#endif
#endif
void flash()
{
static boolean output = HIGH;
digitalWrite(led_pin, output);
output = !output;
}
void setup()
{
pinMode(led_pin, OUTPUT);
MsTimer2::set(500, flash); // 500ms period
MsTimer2::start();
}
void loop()
{
}

View File

@@ -0,0 +1,4 @@
MsTimer2 KEYWORD1
set KEYWORD2
start KEYWORD2
stop KEYWORD2

View File

@@ -0,0 +1,227 @@
/* IR Remote control
* capture a infrared burst from a remote control and generate code template for reproducing that burst
* measure the infrared carrier frequency / capture ir pulse train (max 200 pulses )
* connect the IR receiver Module (IR_reveiver_schematic.jpg)
* to pin 4,5,6,7
*
*
* KHM 2010 / Martin Nawrath
* Kunsthochschule fuer Medien Koeln
* Academy of Media Arts Cologne
*/
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
//! Macro that clears all Timer/Counter1 interrupt flags.
#define CLEAR_ALL_TIMER1_INT_FLAGS (TIFR1 = TIFR1)
int pinLed = 13; // LED connected to digital pin 13
int pinGND = 4; // Ground for IR reveiver Module
int pinVCC = 5; // +5V for IR reveiver Module
int pinAIN0= 6; // Analog Comparator In 0 / IR reveiver Module
int pinAIN1= 7; // Analog Comparator In 0 / IR reveiver Module
int pinTest = 8;
unsigned int khz;
byte bb;
byte bba;
int cnt;
const int maxlen = 300;
int codelen;
unsigned int timecode[maxlen+5];
void setup()
{
pinMode(pinLed, OUTPUT); // sets the digital pin as output
pinMode(pinTest, OUTPUT);
pinMode(pinGND, OUTPUT);
pinMode(pinVCC, OUTPUT);
pinMode(pinAIN0, INPUT);
pinMode(pinAIN1, INPUT);
digitalWrite(pinVCC,1);
digitalWrite(pinGND,0);
Serial.begin(115200); // connect to the serial port
// hardware counter setup ( refer atmega168.pdf chapter 16-bit counter1)
TCCR1A=0; // reset timer/counter1 control register A
TCCR1B=0; // reset timer/counter1 control register A
TCNT1=0; // counter value = 0
// set timer/counter1 hardware as counter , counts events on pin T1 ( arduino pin 5)
// normal mode, wgm10 .. wgm13 = 0
cbi (TCCR1B ,CS10); // no clock
cbi (TCCR1B ,CS11);
cbi (TCCR1B ,CS12);
// timer2 setup / is used for frequency measurement gatetime generation
// timer 2 presaler set to 256 / timer 2 clock = 16Mhz / 256 = 62500 Hz
cbi (TCCR2B ,CS20);
sbi (TCCR2B ,CS21);
sbi (TCCR2B ,CS22);
//set timer2 to CTC Mode
cbi (TCCR2A ,WGM20);
sbi (TCCR2A ,WGM21);
cbi (TCCR2B ,WGM22);
OCR2A = 124; // CTC at top of OCR2A / timer2 interrupt when coun value reaches OCR2A value
// interrupt control
// sbi (TIMSK2,OCIE2A); // enable Timer2 Interrupt
cbi(ADCSRB,ACME);
cbi(ACSR,ACD);
cbi(ACSR,ACBG);
Serial.println(" Infrared code detector");
while ((ACSR & 32) == 0) {
}
khz=f_measure();
Serial.print(khz);
Serial.print( " KHz");
Serial.println( "");
}
void loop()
{
if (ACSR & 32) { // if IR Signal on pin 5 present
TCCR1B=0; //timer1 off
sbi(TIFR1,TOV1); // clear Timer/Counter 1 overflow flag
TCNT1=0; // clear timer1
TCCR1B=3; //timer1 prescaler =64;
bba=0;
cnt=1;
while ((TIFR1 & 1)==0 ) { // wait for T1 period length 250ms TIFR1 Flag
bb=0;
bb = ACSR & 32; // sample IR Strobe Signal for HIGH/LOW
delayMicroseconds(5);
bb =bb | ACSR & 32;
delayMicroseconds(5);
bb =bb | ACSR & 32;
delayMicroseconds(5);
bb =bb | ACSR & 32;
delayMicroseconds(5);
bb =bb | ACSR & 32;
delayMicroseconds(5);
bb =bb | ACSR & 32;
delayMicroseconds(5);
bb =bb | ACSR & 32;
delayMicroseconds(5);
bb =bb | ACSR & 32;
if (bb != bba) { // if IR strobe level changed
PORTB = PORTB ^ 32; // LED blink
timecode[cnt]=TCNT1; // Store Timecode in Table
codelen=TCNT1;
cnt++; // Count IR Strobes
if (cnt > maxlen) cnt =maxlen-1; // cnt max
delayMicroseconds(200);
}
bba=bb;
}
timecode[cnt]=0;
print_code_template();
for (int ii=1;ii < maxlen;ii++) timecode[ii]=0;
}
}
//******************************************************************
// print a code template according to a pressed button
void print_code_template(){
unsigned int ix,ia,ia1,ia2;
char st1[20];
unsigned long int w1,w2;
Serial.println( "//****************** CODE TEMPLATE FOR IR REMOTE ****************************");
Serial.print( "// IR codelength = ");
Serial.print( codelen*4/1000);
Serial.print( " ms");
Serial.println( "");
Serial.print( "ICR1 = 16000 /") ;
Serial.print(khz);
Serial.println( "; // IR carrier frequency") ;
for (ix=1;ix < maxlen;ix+=2) {
ia=timecode[ix];
ia1=timecode[ix+1];
ia2=timecode[ix+2];
if (ia !=0) {
Serial.print( "sbi(DDRB,1); delayMicroseconds(");
w1=ia1-ia;
w1=w1*4;
sprintf(st1, "%4d );", w1);
Serial.print( st1);
timecode[ix]=0;
}
if (ia2 !=0) {
w2=ia2-ia1;
w2=w2*4;
Serial.print( " cbi(DDRB,1); delayMicroseconds(" );
sprintf(st1, "%4d );", w2);
Serial.print( st1);
timecode[ix]=0;
timecode[ix+1]=0;
Serial.print( " // ");
sprintf(st1, "ix:%3d", ix);
Serial.print( st1);
sprintf(st1, " ton:%4d", w1);
Serial.print( st1);
sprintf(st1, " toff:%4d", w2);
Serial.print( st1);
Serial.println("");
}
}
Serial.print( " cbi(DDRB,1);" );
Serial.println("");
Serial.println("");
Serial.println("");
}
//******************************************************************
// measure infrared carrier frequency at pin 6,7 / analog comparator
unsigned int f_measure() {
TCCR1B=0; //timer1 off
sbi(TIFR1,TOV1); // clear Timer/Counter 1 overflow flag
TCNT1=0; // clear timer1
TCCR1B=3; //timer1 prescaler =64;
int cnt=0;
byte bb,bba;
while (TCNT1 < 250) {
bb=ACSR;
if (bb != bba) {
cnt++;
// PORTB ^= 32;
}
bba=bb;
}
cnt=cnt/2;
return (cnt);
}

View File

@@ -0,0 +1,368 @@
/* DVD IR Synchronizer
*
* connect a IR LED to: Anode pin9, Cathode pin8
* KHM 2010 / Martin Nawrath
* Kunsthochschule fuer Medien Koeln
* Academy of Media Arts Cologne
*/
#include <MsTimer2.h>
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
int pinIR_OUT =9;
int pinGND =8;
int pinLED =13;
int bb;
int tics;
int secs;
int f_sec;
int f_sync;
int playtime= 26*60+50; // set here ypur DVD title playtime
void setup() {
pinMode(pinGND,OUTPUT);
Serial.begin(115200);
Serial.println("Panasonic DVD S54 Synchronizer");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
TCCR1A = 0;
cbi(TCCR1A,COM1A0); // timer1 counter control
sbi(TCCR1A,COM1A1); // clear on compare match
cbi(TCCR1A,WGM10); // waveform generation mode 14 TOP=ICR1
sbi(TCCR1A,WGM11);
sbi(TCCR1B,WGM12);
sbi(TCCR1B,WGM13);
sbi(TCCR1B,CS10); // timer 1 clock select
cbi(TCCR1B,CS11); // prescaler=1
cbi(TCCR1B,CS12);
int f_carrier = 37 ; // choose right IR carrier frequency
ICR1 = 16000 / f_carrier ;
OCR1A = 200 ; // Leistung der Sendediode 0..200
pinMode(pinIR_OUT,OUTPUT);
pinMode(pinLED,OUTPUT);
MsTimer2::set(10, ms10); // 10ms period
MsTimer2::start();
Serial.println("play");
send_play();
delay(7000);
secs=playtime;
}
/********************************************************************/
void loop() {
if(f_sec){
f_sec=0;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
if (secs >= playtime){
f_sync=1;
Serial.println("Sync");
Serial.println("pause");
send_pause();
delay(2000);
Serial.println("rev");
send_rev();
delay(2000);
Serial.println("play");
send_play();
secs=0;
f_sync=0;
}
}
}
/********************************************************************/
void ms10() {
tics++;
if (tics >= 100) {
tics=0;
secs++;
//Serial.println("second");
f_sec=1;
PORTB ^= 32;
}
if (f_sync==1)
if ( tics % 10 == 0) PORTB ^= 32;
}
/********************************************************************/
void send_stop() {
sbi(DDRB,1); delayMicroseconds(3472); cbi(DDRB,1); delayMicroseconds(1720); // 1
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(436); // 3
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(1292); // 5
sbi(DDRB,1); delayMicroseconds(456); cbi(DDRB,1); delayMicroseconds(420); // 7
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(432); // 9
sbi(DDRB,1); delayMicroseconds(444); cbi(DDRB,1); delayMicroseconds(436); // 11
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(412); // 13
sbi(DDRB,1); delayMicroseconds(444); cbi(DDRB,1); delayMicroseconds(432); // 15
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(440); // 17
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(420); // 19
sbi(DDRB,1); delayMicroseconds(456); cbi(DDRB,1); delayMicroseconds(420); // 21
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(436); // 23
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(436); // 25
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(412); // 27
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(1316); // 29
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(416); // 31
sbi(DDRB,1); delayMicroseconds(460); cbi(DDRB,1); delayMicroseconds(412); // 33
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(436); // 35
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(412); // 37
sbi(DDRB,1); delayMicroseconds(376); cbi(DDRB,1); delayMicroseconds(24); // 39
sbi(DDRB,1); delayMicroseconds(48); cbi(DDRB,1); delayMicroseconds(432); // 41
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(444); // 43
sbi(DDRB,1); delayMicroseconds(432); cbi(DDRB,1); delayMicroseconds(1292); // 45
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(1308); // 47
sbi(DDRB,1); delayMicroseconds(444); cbi(DDRB,1); delayMicroseconds(412); // 49
sbi(DDRB,1); delayMicroseconds(464); cbi(DDRB,1); delayMicroseconds(1284); // 51
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(440); // 53
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(412); // 55
sbi(DDRB,1); delayMicroseconds(464); cbi(DDRB,1); delayMicroseconds(412); // 57
sbi(DDRB,1); delayMicroseconds(444); cbi(DDRB,1); delayMicroseconds(432); // 59
sbi(DDRB,1); delayMicroseconds(444); cbi(DDRB,1); delayMicroseconds(412); // 61
sbi(DDRB,1); delayMicroseconds(456); cbi(DDRB,1); delayMicroseconds(420); // 63
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(440); // 65
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(420); // 67
sbi(DDRB,1); delayMicroseconds(456); cbi(DDRB,1); delayMicroseconds(412); // 69
sbi(DDRB,1); delayMicroseconds(444); cbi(DDRB,1); delayMicroseconds(432); // 71
sbi(DDRB,1); delayMicroseconds(444); cbi(DDRB,1); delayMicroseconds(436); // 73
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(412); // 75
sbi(DDRB,1); delayMicroseconds(460); cbi(DDRB,1); delayMicroseconds(416); // 77
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(440); // 79
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(420); // 81
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(432); // 83
sbi(DDRB,1); delayMicroseconds(444); cbi(DDRB,1); delayMicroseconds(436); // 85
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(412); // 87
sbi(DDRB,1); delayMicroseconds(464); cbi(DDRB,1); delayMicroseconds(412); // 89
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(440); // 91
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(1288); // 93
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(1308); // 95
sbi(DDRB,1); delayMicroseconds(440); cbi(DDRB,1); delayMicroseconds(436); // 97
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1); delayMicroseconds(1292); // 99
sbi(DDRB,1); delayMicroseconds(436); cbi(DDRB,1);
}
/********************************************************************/
void send_play() {
sbi(DDRB,1); delayMicroseconds( 3476 ); cbi(DDRB,1); delayMicroseconds( 1732 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 412 );
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 1300 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 432 );
sbi(DDRB,1); delayMicroseconds( 448 ); cbi(DDRB,1); delayMicroseconds( 412 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 432 );
sbi(DDRB,1); delayMicroseconds( 448 ); cbi(DDRB,1); delayMicroseconds( 412 );
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 424 );
sbi(DDRB,1); delayMicroseconds( 432 ); cbi(DDRB,1); delayMicroseconds( 444 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 424 );
sbi(DDRB,1); delayMicroseconds( 432 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 420 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 1296 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 444 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 420 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 432 ); cbi(DDRB,1); delayMicroseconds( 424 );
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 424 );
sbi(DDRB,1); delayMicroseconds( 432 ); cbi(DDRB,1); delayMicroseconds( 1292 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 1312 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 412 );
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 1300 );
sbi(DDRB,1); delayMicroseconds( 432 ); cbi(DDRB,1); delayMicroseconds( 424 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 432 );
sbi(DDRB,1); delayMicroseconds( 448 ); cbi(DDRB,1); delayMicroseconds( 432 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 412 );
sbi(DDRB,1); delayMicroseconds( 448 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 420 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 444 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 444 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 412 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 1312 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 420 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 1296 );
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 412 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 420 ); cbi(DDRB,1); delayMicroseconds( 436 );
sbi(DDRB,1); delayMicroseconds( 432 ); cbi(DDRB,1); delayMicroseconds( 448 );
sbi(DDRB,1); delayMicroseconds( 432 ); cbi(DDRB,1); delayMicroseconds( 1300 );
sbi(DDRB,1); delayMicroseconds( 436 ); cbi(DDRB,1); delayMicroseconds( 432 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 1292 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 1288 );
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 1292 );
sbi(DDRB,1); delayMicroseconds( 444 ); cbi(DDRB,1); delayMicroseconds( 432 );
sbi(DDRB,1); delayMicroseconds( 448 ); cbi(DDRB,1); delayMicroseconds( 1288 );
sbi(DDRB,1); delayMicroseconds( 432 ); cbi(DDRB,1); delayMicroseconds( 0 );
}
/********************************************************************/
void send_pause() {
ICR1 = 16000 /37; // IR carrier frequency
sbi(DDRB,1); delayMicroseconds(3500 ); cbi(DDRB,1); delayMicroseconds(1708 ); // ix: 1 ton:3500 toff:1708
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 3 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1264 ); // ix: 5 ton: 456 toff:1264
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 7 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 384 ); // ix: 9 ton: 464 toff: 384
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 11 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 13 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 388 ); // ix: 15 ton: 456 toff: 388
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 17 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 19 ton: 460 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 21 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 23 ton: 424 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 25 ton: 460 toff: 420
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 27 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 420 ); cbi(DDRB,1); delayMicroseconds(1308 ); // ix: 29 ton: 420 toff:1308
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 31 ton: 460 toff: 420
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 33 ton: 424 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 35 ton: 460 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 37 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 388 ); // ix: 39 ton: 460 toff: 388
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 41 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1304 ); // ix: 43 ton: 456 toff:1304
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds(1304 ); // ix: 45 ton: 424 toff:1304
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 47 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1272 ); // ix: 49 ton: 456 toff:1272
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 51 ton: 456 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 53 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 55 ton: 424 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 57 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 59 ton: 456 toff: 424
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 61 ton: 424 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 63 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 65 ton: 456 toff: 424
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 67 ton: 424 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds(1300 ); // ix: 69 ton: 464 toff:1300
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds(1268 ); // ix: 71 ton: 460 toff:1268
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 73 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 75 ton: 460 toff: 420
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 77 ton: 424 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 79 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 81 ton: 460 toff: 420
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 83 ton: 424 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds(1300 ); // ix: 85 ton: 460 toff:1300
sbi(DDRB,1); delayMicroseconds( 428 ); cbi(DDRB,1); delayMicroseconds(1300 ); // ix: 87 ton: 428 toff:1300
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 89 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1272 ); // ix: 91 ton: 456 toff:1272
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1300 ); // ix: 93 ton: 456 toff:1300
sbi(DDRB,1); delayMicroseconds( 428 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 95 ton: 428 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds(1300 ); // ix: 97 ton: 464 toff:1300
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1);
}
/********************************************************************/
void send_rev() {
ICR1 = 16000 /37; // IR carrier frequency
sbi(DDRB,1); delayMicroseconds(3500 ); cbi(DDRB,1); delayMicroseconds(1708 ); // ix: 1 ton:3500 toff:1708
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 3 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1268 ); // ix: 5 ton: 456 toff:1268
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 7 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 9 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 420 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 11 ton: 420 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 13 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 15 ton: 456 toff: 424
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 17 ton: 424 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 19 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 21 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 388 ); // ix: 23 ton: 460 toff: 388
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 25 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 27 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 420 ); cbi(DDRB,1); delayMicroseconds(1300 ); // ix: 29 ton: 420 toff:1300
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 31 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 384 ); // ix: 33 ton: 464 toff: 384
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 35 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 37 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 39 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 420 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 41 ton: 420 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds(1300 ); // ix: 43 ton: 464 toff:1300
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds(1264 ); // ix: 45 ton: 464 toff:1264
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 47 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1268 ); // ix: 49 ton: 456 toff:1268
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 51 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 53 ton: 460 toff: 420
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 55 ton: 424 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 57 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 59 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 420 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 61 ton: 420 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 63 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 65 ton: 464 toff: 420
sbi(DDRB,1); delayMicroseconds( 428 ); cbi(DDRB,1); delayMicroseconds(1300 ); // ix: 67 ton: 428 toff:1300
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 428 ); // ix: 69 ton: 456 toff: 428
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds( 392 ); // ix: 71 ton: 456 toff: 392
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1304 ); // ix: 73 ton: 456 toff:1304
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 75 ton: 460 toff: 420
sbi(DDRB,1); delayMicroseconds( 428 ); cbi(DDRB,1); delayMicroseconds( 420 ); // ix: 77 ton: 428 toff: 420
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1308 ); // ix: 79 ton: 456 toff:1308
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 384 ); // ix: 81 ton: 460 toff: 384
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds(1304 ); // ix: 83 ton: 460 toff:1304
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 384 ); // ix: 85 ton: 460 toff: 384
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds( 424 ); // ix: 87 ton: 460 toff: 424
sbi(DDRB,1); delayMicroseconds( 460 ); cbi(DDRB,1); delayMicroseconds(1304 ); // ix: 89 ton: 460 toff:1304
sbi(DDRB,1); delayMicroseconds( 424 ); cbi(DDRB,1); delayMicroseconds(1300 ); // ix: 91 ton: 424 toff:1300
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1); delayMicroseconds(1264 ); // ix: 93 ton: 464 toff:1264
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1308 ); // ix: 95 ton: 456 toff:1308
sbi(DDRB,1); delayMicroseconds( 456 ); cbi(DDRB,1); delayMicroseconds(1264 ); // ix: 97 ton: 456 toff:1264
sbi(DDRB,1); delayMicroseconds( 464 ); cbi(DDRB,1);
}

View File

@@ -0,0 +1,423 @@
/* DVD IR Synchronizer
*
* connect a IR LED to: Anode pin9, Cathode pin8
* KHM 2010 / Martin Nawrath
* Kunsthochschule fuer Medien Koeln
* Academy of Media Arts Cologne
*/
#include <MsTimer2.h>
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
int pinIR_OUT =9;
int pinGND =8;
int pinLED =13;
int bb;
int tics;
int secs;
int f_sec;
int f_sync;
int playtime= 40*60+30; // set here ypur DVD title playtime
void setup() {
pinMode(pinGND,OUTPUT);
Serial.begin(115200);
Serial.println("DVD Synchronizer");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
TCCR1A = 0;
cbi(TCCR1A,COM1A0); // timer1 counter control
sbi(TCCR1A,COM1A1); // clear on compare match
cbi(TCCR1A,WGM10); // waveform generation mode 14 TOP=ICR1
sbi(TCCR1A,WGM11);
sbi(TCCR1B,WGM12);
sbi(TCCR1B,WGM13);
sbi(TCCR1B,CS10); // timer 1 clock select
cbi(TCCR1B,CS11); // prescaler=1
cbi(TCCR1B,CS12);
int f_carrier = 37 ; // choose right IR carrier frequency
ICR1 = 16000 / f_carrier ;
OCR1A = 200 ; // Leistung der Sendediode 0..200
pinMode(pinIR_OUT,OUTPUT);
pinMode(pinLED,OUTPUT);
MsTimer2::set(10, ms10); // 10ms period
MsTimer2::start();
Serial.println("play");
send_play();
delay(7000);
secs=playtime;
}
/********************************************************************/
void loop() {
if(f_sec){
f_sec=0;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
if (secs >= playtime){
f_sync=1;
Serial.println("Sync");
Serial.println("pause");
send_pause();
delay(2000);
Serial.println("rev");
send_rev();
delay(2000);
Serial.println("play");
send_play();
secs=0;
f_sync=0;
}
}
}
/********************************************************************/
void ms10() {
tics++;
if (tics >= 100) {
tics=0;
secs++;
f_sec=1;
PORTB ^= 32;
}
if (f_sync==1)
if ( tics % 10 == 0) PORTB ^= 32;
}
/********************************************************************/
void send_stop() {
ICR1 = 16000 /40; // ICR1 = 16000 /40; // IR carrier frequency
sbi(DDRB,1); delayMicroseconds(2400 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 1 ton:2400 toff: 572
sbi(DDRB,1); delayMicroseconds( 648 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 3 ton: 648 toff: 564
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 5 ton: 608 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 7 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds(1236 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 9 ton:1236 toff: 564
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 11 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 576 ); // ix: 13 ton:1228 toff: 576
sbi(DDRB,1); delayMicroseconds( 636 ); cbi(DDRB,1); delayMicroseconds( 576 ); // ix: 15 ton: 636 toff: 576
sbi(DDRB,1); delayMicroseconds( 636 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 17 ton: 636 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 576 ); // ix: 19 ton:1228 toff: 576
sbi(DDRB,1); delayMicroseconds( 600 ); cbi(DDRB,1); delayMicroseconds( 612 ); // ix: 21 ton: 600 toff: 612
sbi(DDRB,1); delayMicroseconds(1188 ); cbi(DDRB,1); delayMicroseconds( 612 ); // ix: 23 ton:1188 toff: 612
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 600 ); // ix: 25 ton:1192 toff: 600
sbi(DDRB,1); delayMicroseconds(1200 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 27 ton:1200 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 29 ton: 608 toff: 564
sbi(DDRB,1); delayMicroseconds( 648 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 31 ton: 648 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 33 ton:1228 toff: 564
sbi(DDRB,1); delayMicroseconds( 648 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 35 ton: 648 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 37 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 600 ); // ix: 39 ton:1228 toff: 600
sbi(DDRB,1); delayMicroseconds( 612 ); cbi(DDRB,1); delayMicroseconds(13252 ); // ix: 41 ton: 612 toff:13252
sbi(DDRB,1); delayMicroseconds(2400 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 43 ton:2400 toff: 608
sbi(DDRB,1); delayMicroseconds( 612 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 45 ton: 612 toff: 564
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 47 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 49 ton: 608 toff: 604
sbi(DDRB,1); delayMicroseconds(1196 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 51 ton:1196 toff: 604
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 53 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 612 ); // ix: 55 ton:1192 toff: 612
sbi(DDRB,1); delayMicroseconds( 600 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 57 ton: 600 toff: 572
sbi(DDRB,1); delayMicroseconds( 648 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 59 ton: 648 toff: 564
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 61 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 63 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 576 ); // ix: 65 ton:1228 toff: 576
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 67 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 69 ton:1228 toff: 564
sbi(DDRB,1); delayMicroseconds( 612 ); cbi(DDRB,1); delayMicroseconds( 600 ); // ix: 71 ton: 612 toff: 600
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 576 ); // ix: 73 ton: 608 toff: 576
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 75 ton:1228 toff: 564
sbi(DDRB,1); delayMicroseconds( 648 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 77 ton: 648 toff: 572
sbi(DDRB,1); delayMicroseconds( 600 ); cbi(DDRB,1); delayMicroseconds( 612 ); // ix: 79 ton: 600 toff: 612
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 81 ton:1228 toff: 564
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds(13256 ); // ix: 83 ton: 608 toff:13256
sbi(DDRB,1); delayMicroseconds(2436 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 85 ton:2436 toff: 572
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 87 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 89 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 91 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 93 ton:1232 toff: 568
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 95 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 97 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 99 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:101 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:103 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:105 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:107 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 576 ); // ix:109 ton:1228 toff: 576
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix:111 ton:1228 toff: 564
sbi(DDRB,1); delayMicroseconds( 648 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix:113 ton: 648 toff: 564
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:115 ton: 608 toff: 572
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 600 ); // ix:117 ton:1232 toff: 600
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 576 ); // ix:119 ton: 608 toff: 576
sbi(DDRB,1); delayMicroseconds( 636 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:121 ton: 636 toff: 572
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:123 ton:1232 toff: 572
sbi(DDRB,1); delayMicroseconds( 600 ); cbi(DDRB,1);
}
/********************************************************************/
void send_play() {
ICR1 = 16000 /40; // IR carrier frequency
sbi(DDRB,1); delayMicroseconds(2400 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 1 ton:2400 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 3 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 5 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 7 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 9 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 11 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 13 ton:1228 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 15 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 17 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 19 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 21 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 23 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 25 ton:1192 toff: 604
sbi(DDRB,1); delayMicroseconds(1236 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 27 ton:1236 toff: 564
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 29 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 31 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 33 ton:1232 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 35 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 37 ton: 608 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 39 ton:1228 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds(13256 ); // ix: 41 ton: 608 toff:13256
sbi(DDRB,1); delayMicroseconds(2400 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 43 ton:2400 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 45 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 47 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 49 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 51 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 53 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 55 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 57 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 59 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 61 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 63 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 65 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 67 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 69 ton:1232 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 71 ton: 608 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 73 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 75 ton:1232 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 77 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 79 ton: 608 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 81 ton:1192 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds(13252 ); // ix: 83 ton: 608 toff:13252
sbi(DDRB,1); delayMicroseconds(2440 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 85 ton:2440 toff: 572
sbi(DDRB,1); delayMicroseconds( 600 ); cbi(DDRB,1); delayMicroseconds( 576 ); // ix: 87 ton: 600 toff: 576
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 89 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 91 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 93 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 95 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 97 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 99 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:101 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:103 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:105 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:107 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:109 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:111 ton:1232 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:113 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix:115 ton: 608 toff: 604
sbi(DDRB,1); delayMicroseconds(1196 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix:117 ton:1196 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:119 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:121 ton: 644 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:123 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1);
}
/********************************************************************/
void send_pause() {
ICR1 = 16000 /40; // IR carrier frequency
sbi(DDRB,1); delayMicroseconds(2404 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 1 ton:2404 toff: 568
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 3 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 5 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 7 ton: 608 toff: 604
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 9 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 11 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 13 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 15 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 17 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 19 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 21 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 23 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 25 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds(1236 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 27 ton:1236 toff: 564
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 29 ton: 608 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 31 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds(1236 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 33 ton:1236 toff: 564
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 35 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 37 ton: 644 toff: 572
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 39 ton:1232 toff: 564
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds(12664 ); // ix: 41 ton: 608 toff:12664
sbi(DDRB,1); delayMicroseconds(2408 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 43 ton:2408 toff: 604
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 45 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 47 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 49 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 51 ton:1232 toff: 568
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 53 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 55 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 57 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 59 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 61 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 63 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 65 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 67 ton:1228 toff: 604
sbi(DDRB,1); delayMicroseconds(1196 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 69 ton:1196 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 71 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 73 ton: 644 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 75 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 77 ton: 608 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 79 ton: 608 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 81 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds(12628 ); // ix: 83 ton: 644 toff:12628
sbi(DDRB,1); delayMicroseconds(2408 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 85 ton:2408 toff: 604
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 87 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 89 ton: 608 toff: 564
sbi(DDRB,1); delayMicroseconds( 648 ); cbi(DDRB,1); delayMicroseconds( 564 ); // ix: 91 ton: 648 toff: 564
sbi(DDRB,1); delayMicroseconds(1236 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 93 ton:1236 toff: 568
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 95 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 97 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 99 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix:101 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix:103 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:105 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:107 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix:109 ton:1228 toff: 604
sbi(DDRB,1); delayMicroseconds(1196 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix:111 ton:1196 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:113 ton: 608 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:115 ton: 644 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:117 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix:119 ton: 608 toff: 604
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:121 ton: 608 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:123 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1);
}
/********************************************************************/
void send_rev() {
ICR1 = 16000 /40; // IR carrier frequency
sbi(DDRB,1); delayMicroseconds(2400 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 1 ton:2400 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 3 ton: 644 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 5 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 7 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 9 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 11 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 13 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 15 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 17 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 19 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 21 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 23 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 25 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds(1232 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 27 ton:1232 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 29 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 31 ton: 608 toff: 608
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 33 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 35 ton: 608 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 37 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 39 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds(13808 ); // ix: 41 ton: 644 toff:13808
sbi(DDRB,1); delayMicroseconds(2436 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 43 ton:2436 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 45 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 47 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 49 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 51 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 53 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 55 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 57 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 59 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 61 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 63 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 65 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 67 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 69 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 71 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 73 ton: 644 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 75 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 77 ton: 608 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 79 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 81 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds(13844 ); // ix: 83 ton: 644 toff:13844
sbi(DDRB,1); delayMicroseconds(2436 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 85 ton:2436 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 87 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 89 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix: 91 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 604 ); // ix: 93 ton: 608 toff: 604
sbi(DDRB,1); delayMicroseconds(1188 ); cbi(DDRB,1); delayMicroseconds( 612 ); // ix: 95 ton:1188 toff: 612
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix: 97 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix: 99 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:101 ton: 644 toff: 568
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:103 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds( 640 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:105 ton: 640 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:107 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:109 ton:1228 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:111 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 608 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix:113 ton: 608 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:115 ton: 604 toff: 572
sbi(DDRB,1); delayMicroseconds(1228 ); cbi(DDRB,1); delayMicroseconds( 568 ); // ix:117 ton:1228 toff: 568
sbi(DDRB,1); delayMicroseconds( 644 ); cbi(DDRB,1); delayMicroseconds( 572 ); // ix:119 ton: 644 toff: 572
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix:121 ton: 604 toff: 608
sbi(DDRB,1); delayMicroseconds(1192 ); cbi(DDRB,1); delayMicroseconds( 608 ); // ix:123 ton:1192 toff: 608
sbi(DDRB,1); delayMicroseconds( 604 ); cbi(DDRB,1);
}

5
synchronizer/readme.txt Normal file
View File

@@ -0,0 +1,5 @@
To install arduino libraries put them in
Documents/Arduino/libraries
Directions on setting up the IR remote system are at
http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html

View File

@@ -0,0 +1,25 @@
/*
* Remote Test for Toshiba DVD player
* by Joe Foley <foley@mit.edu>
* Codes from http://lirc.sourceforge.net/remotes/toshiba/SE-R0313
* IRRemote library at http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
* A random text file says that Toshiba uses the NEC protocol
*/
#include <IRremote.h>
#define ToshibaAddress 0xA25D // Panasonic address (Pre data)
#define TobshibaPower 0x48B7 // Panasonic Power button
IRsend irsend;
void setup()
{
Serial.begin(115200);
Serial.println("IRremote test for Toshiba SD560EKE");
}
void loop() {
irsend.sendNEC(ToshibaAddress,ToshibaPower); // This should turn your TV on and off
delayMicroseconds(500);
}

View File

@@ -0,0 +1,44 @@
/*
* Remote Test for Toshiba DVD player
* by Joe Foley <foley@mit.edu>
* Codes from http://lirc.sourceforge.net/remotes/toshiba/SE-R0313
* IRRemote library at http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
* A random text file says that Toshiba uses the NEC protocol
*/
#include <IRremote.h>
#define ToshibaAddress 0xA25D // Toshiba address (Pre data)
#define ToshibaPower 0x48B7 // Toshiba Power button
IRsend irsend;
void setup()
{
Serial.begin(115200);
Serial.println("IRremote test for Toshiba SD560EKE $Rev$");
Serial.println("$URL$");
Serial.println("$Id$");
// power
//irsend.sendNEC(0xA25D48B7,32);
//delayMicroseconds(200);
}
void loop() {
// pause
irsend.sendNEC(0xA25D00FF, 32);
delay(2000);
// previous
irsend.sendNEC(0xA25DC43B, 32);
delay(2000);
//play
irsend.sendNEC(0xA25DA857,32);
delay(10000);
}

View File

@@ -0,0 +1,57 @@
/* Philips DVD player codefinder
* Code written by Joe Foley <foley@ru.is>
* on 2013-09-08
*
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
* Instructions http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
*
* The IRremote library uses Pin 3 for the Anode (longer pin)
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*/
#include <IRremote.h>
int pinGND=4; // Longer leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
IRsend irsend;
unsigned long testcode;
void setup() {
pinMode(pinGND,OUTPUT);
pinMode(pinLED,OUTPUT);
Serial.begin(115200);
Serial.println("Philips Codefinder $Rev$");
Serial.println("Code by Joe Foley <foley@ru.is>");
Serial.println("$URL$");
Serial.println("$Id$");
}
/********************************************************************/
void loop() {
for (int address = 0; address < 0x100; address++) {
for (int command = 0; command < 0x100; command++) {
Serial.print("address: ");
Serial.print(address, HEX);
Serial.print(" command: ");
Serial.print(command, HEX);
testcode = ( address << 16 ) + command;
Serial.print(" testcode: ");
Serial.println(testcode, HEX);
irsend.sendRC6(testcode, 16);
}
}
}
/**************************************************************/
void waitsec(int sec) {
Serial.print("Wait ");
Serial.print(sec);
Serial.println(" seconds");
delay(sec*1000);
}