How I can control my relay to work for a period of time?

Hello dear members,
I am currently working on ordering a lamp to work for for a period of time.
The way my algorithm works is the following:
First I measure the brightness and then I use an equation to calculate the duration of operation of my lamp (T=(60) /(Brightness+10)).
For example : If Brightness = 30% Then lamp runtime equals T=(60) /(30+10) = 90sec

My question is : how can I control my relay to work for the same duration calculated by my equation? is there a code to do this task?

Hi,
Can you please post your code and your circuit?

Yes

Show us a good schematic of your circuit.

Show us a good image of your ‘actual’ wiring.

Give links to components.


In the Arduino IDE, use Ctrl T to format your code then copy the complete sketch.

Use the </> button from the ‘reply menu’ to attach the copied sketch.

Hello
I gues a simple timer funktion shall do this job.

That is a magic calculation:
T=(60) /(30+10) = 90sec
Or do I miss a magic brightness factor? :nerd_face:

it's just a typing mistake, instead of writing 1,5( in minute) I wrote in second (sec).

Can you help me in code?

Hello
Do the figures inside the equation have names?
Which are variable or constant?

They are just constant; the variables are: time and Brightness (T=(60) /(Brightness+10)).

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.