Hi,
Here is the code with the 0x____ :
/* ------------------------------------------------------------
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
Thanks