LED Driver for Luminous Flux and Correlated Color Temperature

Greetings!

I’m rather new to Arduino and any microcontrollers, and I’m currently doing a project on illumination.

My idea is to control the luminous flux and the correlated color temperature (CCT) of a room using two LED strips with different CCT values, 3700K and 5000K.

To switch the LED strips, I’m PWMing the IRF540 MOSFET and to sense both luminous flux and CCT I’m using the TCS3414 sensor with I2C communication.

As far as the electronics go, I’ve already tested it and it worked pretty fine (was able to see the square wave in all stages where it needed to be).

However, when I try to burn my code in the Arduino UNO with the PCB connected, it won’t work, I get an error message, which is attached in this post. When I disconnect the PCB, the code will burn effotlessly in the Arduino (or, rather, the ATmega328P but let’s leave it at that). There are times when the code will burn into the Arduino even with the PCB connected.

But, since I want to experimentally set the PI constants of my feedback control, I need to use the serial monitor. When I open it up, nothing shows.

So, I want to know: is this a common issue? Is it fixable? Are there any errors in my electronic project that are inhibiting the serial monitor and the AVRdude to work properly?

Low Side MOSFET-based LED Driver.PDF (33.6 KB)

LED_DRIVE_v1.ino (5.52 KB)

nathan_maruch:
However, when I try to burn my code in the Arduino UNO with the PCB connected, it won't work, I get an error message, which is attached in this post.

Can't see any attached error message.... ?

Yours,
TonyWilk

Sketch does not compile.

  1. "cte was not declared in this scope" means that you haven't declared that variable (in the #define area).

  2. 'else' (line 191) has a condition added to it. Only if() or else if() can have conditions.

Not sure if the sensor is slow enough to smoothen PWM controlled light.
Humans see PWM controlled LEDs as dimming, but light sensors could see it as 100% on and off.

Read the forum rules about posting code inline.
Leo..

Sorry, forgot to attach it.

Here it is.

There’s also sometimes an error where it says something about AVRdude, with 10 tries to do something. Never really paid any attention to it, sadly.

Thank you.

Wawa, thank you for your reply.

  1. cte is the constant which I was planning to adjust to better balance my system and achieve better control. So I forgot to set an initial value, I’m sorry.

  2. Programming is not really my thing. It worked! I’m so pissed at myself right now… But, well, thank you. Really.

And this sensor is slow enough to more or less simulate a human eye based on the XYZ values of the CIE 1931 XYZ Color Space. Now on to the feedback control constants!

I’ll read the rules, sorry if I did anything not according to the rules.