Hi Guys
I could really do with some guidance on this project.
I am currently looking at powering an LED off pin 13 on the Arduino Uno R3, currently I have two Arduinos communicating with each other via Infrared, one being the transmitter and the other the receiver.
I am hoping to turn on the LED at the receiver at a reduced lumen output, 10-20% and increasing the output to 100% over a couple of seconds. If no further communication is received by the transmitter I am also wanting to turn the LED off after a set time period. I have sourced and modified basic IR code and PWM dimming code separately but am failing at combining the two.
I would really appreciate any help and advice on the programming side of things as I am new to Arduino.
Thank you for your time.
Current Code for Receiver On/Off Function
#include <IRremote.h> //adds the library code to the sketch
const int irReceiverPin = 2; //pin the receiver is connected to
const int ledPin = 13;
IRrecv irrecv(irReceiverPin); //create an IRrecv object
decode_results decodedSignal; //stores results from IR detector
void setup()
{
pinMode(ledPin, OUTPUT);
irrecv.enableIRIn();
}
boolean lightState = false;
unsigned long last = millis();
// Start the receiver object
//keep track of whether the LED is on
//remember when we last received an IR
void loop()
{
if (irrecv.decode(&decodedSignal) == true) //this is true if a message has been received
{
if (millis() - last > 250) {
//has it been 1/4 sec since last message
lightState = !lightState;
//toggle the LED
digitalWrite(ledPin, lightState);
}
last = millis();
irrecv.resume();
// watch out for another message
}
}