It might look like the Apple code to you, but the compiler is seeing the floating point constant 77E1 (or 77 x 101), followed by BA8B, which it doesn't know what to do with.
If that is meant to be a hex constant, then it should be prefixed with 0x.
ARC_Instructables:106: error: integer constant is too large for 'long' type
ARC_Instructables:119: error: integer constant is too large for 'long' type
I used the IRrecvDemo sketch from here:
It outputs this when I press of the remote key, in this case:
/* ------------------------------------------------------------
This sketch decodes IR signals sent to Arduino in response to
buttons pressed on an Apple Remote controlling ouput of an LED
attached to pin 10.
o Play/Pause switches LED On / Standby
o Brightness control '+' and '-' buttons
o Modes '<<' and '>>' buttons
o 'Menu' RESETS all values to default (brightness, constant on)
MODES:
0 - Constant On
1 - Blink
2 - Strobe
3 - Fade in/out
4 - Hypermixfade
Author: A.dlP
Library: IRremote by Ken Sherriff
Date Modified: 28th October 2010
For: 'Control Arduino with IR Apple Remote' instructable.
URL: http://www.instructables.com
-------------------------------------------------------------- */
#include <IRremote.h>
//#include <IRremoteInt.h>
int RECV_PIN = 9; // IR Receiver pin
int ledPin = 13; // On board LED
int ledExPin = 10; // External 5mm White LED
int delay0 = 60; // LED visible time
int delay1 = 200; // 'Blink' interval
int delay2 = 25; // 'Strobe' interval
IRrecv irrecv(RECV_PIN);
decode_results results;
// Create values for 'storing' states
int centreButtonState = 0; // counts how many times centre 'Play/Pause' has been pressed
int brightness = 100; // stores brightness level
int mode = 0; // stores activity modes
// Setup & Configuration
void setup()
{
// initialize serial communications at 9600 bps:
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(ledPin, OUTPUT); // define ledPin as an output
pinMode(ledExPin, OUTPUT);
analogWrite(ledExPin, brightness); // LED PWM's at brightness value
}
/// M O D E S ///
void slowBlink() {
analogWrite(ledExPin, brightness);
delay(delay1);
analogWrite(ledExPin, 0);
delay(delay1);
}
void strobe() {
analogWrite(ledExPin, brightness);
delay(delay0);
analogWrite(ledExPin, 0);
delay(delay2);
}
void fade() {
for(int fadeValue = 0 ; fadeValue <= brightness; fadeValue +=5) {
analogWrite(ledExPin, fadeValue);
delay(30);
}
for(int fadeValue = brightness ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledExPin, fadeValue);
delay(30);
}
}
void hypermixFade() {
for(int fadeValue = 0 ; fadeValue <= brightness; fadeValue +=5) {
analogWrite(ledExPin, fadeValue);
delay(30);
}
for(int x = 0; x < 6; x++) { // repeat 'slowBlink' 5x
slowBlink();
}
for(int x = 0; x < 6; x++) { // repeat 'strobe' 5x
strobe();
}
for(int fadeValue = brightness ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledExPin, fadeValue); // fade out
delay(30);
}
}
// Main Loop
void loop() {
if (irrecv.decode(&results)) { // if an IR signal is obtained from IR receiver
// When Centre button is pressed
if(results.value == 0x2011242643) {
if(centreButtonState == LOW) { // if previously LOW
centreButtonState = HIGH; // now make HIGH
Serial.println("ACTIVE");
}
else { // if already HIGH
centreButtonState = LOW; // now make LOW
Serial.println("STANDBY");
}
}
// When '+' volume button pressed
if(results.value == 0x2011287699 && brightness < 240) { // if '+' volume button pressed
brightness = brightness +20; // add +20 to brightness val
Serial.print("Brightness increased to ");
Serial.println(brightness); // print the new value
}
// When '-' volume button pressed
if(results.value == 0x2011279507 && brightness > 0) { // if '-' volume button pressed and brightness isn't less than 0
brightness = brightness -20; // subtract -20 from brightness val
Serial.print("Brightness decreased to ");
Serial.println(brightness); // print the new value
}
// When previous '<<' button pressed
if(results.value == 0x2011238547) {
if(mode > 0) {
mode = mode -1;
}
else {
mode = 4;
}
Serial.print("Mode: ");
Serial.println(mode);
}
// When next '>>' button pressed
if(results.value == 0x2011291795) {
if(mode < 4) {
mode = mode +1;
}
else {
mode = 0;
}
Serial.print("Mode: ");
Serial.println(mode);
}
// When 'menu' button pressed, RESET ALL VALUES TO DEFAULT
if(results.value == 0x2011250835) {
centreButtonState = HIGH;
brightness = 100;
mode = 0;
Serial.println("RESET");
}
irrecv.resume(); // Receive the next value
}
switch (mode) { // Mode Management
case 0:
// Serial.println("Constant");
if(centreButtonState == HIGH) {
analogWrite(ledExPin, brightness);
}
else {
analogWrite(ledExPin, 0);
}
break;
case 1:
// Serial.println("Slow Blink");
if(centreButtonState == HIGH) {
slowBlink();
}
break;
case 2:
// Serial.println("Strobe");
if(centreButtonState == HIGH) {
strobe();
}
break;
case 3:
// Serial.println("Fade");
if(centreButtonState == HIGH) {
fade();
}
break;
case 4:
// Serial.println("HypermixFade");
if(centreButtonState == HIGH) {
hypermixFade();
}
break;
}
}
Compile Error for above sketch:
ARC_Instructables:106: error: integer constant is too large for 'long' type
ARC_Instructables:119: error: integer constant is too large for 'long' type
ARC_Instructables:126: error: integer constant is too large for 'long' type
ARC_Instructables:133: error: integer constant is too large for 'long' type
ARC_Instructables:145: error: integer constant is too large for 'long' type
ARC_Instructables:157: error: integer constant is too large for 'long' type
/*
* 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)
*/
#include <Arduino.h>
#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
The IR Receiver Dump sketch is working, outputs to serial monitor:
77E1D08B
Decoded NEC: 77E1D08B (32 bits)
However, I don't know if this is a HEX number or not. Is it?
I also notice the end of NEC 32bit is 8B. I removed these and it seems to compile without errors.
However, nothing happens, when remote button is pressed.