// include the library code:
#include <LiquidCrystal.h> // use the library for Display
#include <IRremote.h> // use the library for IR
const int receiver = 10; // pin of IR receiver to Arduino
const int bulb = 9; // To bulb or whatever you connect.
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int fadeValue;
int lastCounter = 1;
int counter;
#define code1 32895 // code received from button A
#define code2 36975 // code received from button B
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;
void setup() {
[Link](9600); // you can comment this line
//Set up the output pin
pinMode(bulb, OUTPUT);
//Ir
[Link]();
// set up the LCD's number of columns and rows:
[Link](16, 2);
[Link](0, 0); // set cursor to top left & first colum
[Link]("Hello");
delay(1000);
[Link](0, 0);
[Link]("Starting..");
delay(1000);
[Link]();
void loop() {
counter = lastCounter;
if ([Link](&results))
unsigned int value = [Link];
if (value == code1) {
counter ++;
[Link]();// clear lcd
if (value == code2) {
counter --;
[Link](); // clear lcd
[Link]("IR receive code"); [Link](value); // you can comment this line
[Link]();
if (counter > 5) { //maximum for counter = 5
counter = 5;
if (counter < 2) { //minimum for counter = 1
counter = 1;
switch (counter) { //depending on the counter the fadevalue is sent to the led
case 1:
fadeValue = 00;
[Link](0, 0); // set cursor to top right
[Link]("Dimmer! - OFF"); // LCD print
[Link](0, 1); // set cursor to bottom left & second colum
[Link]("PRES VOL+"); // LCD print
break;
case 2:
fadeValue = 50;
[Link](0, 0); // set cursor to top right
[Link]("Dimmer! - ON "); // LCD print
[Link](0, 1); // set cursor to bottom left & second colum
[Link]("Speed 1"); // LCD print
break;
case 3:
fadeValue = 100;
[Link](0, 0); // set cursor to top right
[Link]("Dimmer! - ON "); // LCD print
[Link](0, 1); // set cursor to bottom left & second colum
[Link]("Speed 2"); // LCD print
break;
case 4:
fadeValue = 185;
[Link](0, 0); // set cursor to top right
[Link]("Dimmer! - ON "); // LCD print
[Link](0, 1); // set cursor to bottom left & second colum
[Link]("Speed 3"); // LCD print
break;
case 5:
fadeValue = 255;
[Link](0, 0); // set cursor to top right
[Link]("Dimmer! - MAX"); // LCD print
[Link](0, 1); // set cursor to bottom left & second colum
[Link]("PRES VOL-"); // LCD print
break;
analogWrite(bulb, fadeValue); //set led with PWM value
lastCounter = counter; //reset counter