TJ Blevins
Published © LGPL

Countertop Lighting Arduino Control

Countertop lighting? No problem!

BeginnerProtip4 hours3,015
Countertop Lighting Arduino Control

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Power MOSFET N-Channel
Power MOSFET N-Channel
One that can handle the amperage of the led strip used.
×1
IR receiver (generic)
×1

Hand tools and fabrication machines

Dremel

Story

Read more

Code

CounterTopControl

Arduino
Your remote will most likely have different readings check the buttons you'd like to use before adding them to the if statements.
#include <IRremote.h>

int RECV_PIN = 11;
const int underLeds = 6;

int lightState = 0;
int lightValue = 0;
int flag;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
  // In case the interrupt driver crashes on setup, give a clue
  // to the user what's going on.
  Serial.println("Enabling IRin");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Enabled IRin");
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    //irrecv.resume(); // Receive the next value
  
  if(results.value == 33441975){
     //lights on
     lightState = 1;
     flag = flag + 1;
     //Serial.println("ON");
     lightValue = 250;
     analogWrite(underLeds, lightValue);
  }
 
  if(results.value == 33448095 && lightState == 1){
    lightValue = lightValue + 10;
    analogWrite(underLeds, lightValue);
    }

   if(results.value == 33464415 && lightState == 1){
      lightValue = lightValue - 10;
      analogWrite(underLeds, lightValue);
   
}
  if(results.value == 33441975 && flag == 2){
    //check if leds are on then turn off.
    flag = 0;
    Serial.println("OFF");
    analogWrite(underLeds, 0);
  }
 irrecv.resume();
  }
 //irrecv.resume();
  
}

Credits

TJ Blevins
3 projects • 5 followers
Contact

Comments

Please log in or sign up to comment.