Project: Tester of light sources , need little advice

I need your help guys on my project Arduino light sources tester

I need help with my project a light source tester (low power bulbs). The tester must be able to measure the light intensity, the temperature of enviroment, the number of switching and shutdowns of bulb, the total test time and on the basis of these measurements, evaluate the lifetime of the light source. I have three microswitches to be programmed, each for another time interval between switching on and off the relay. I have three questions to you:

  1. How to program Ardito UNO to wait for me to press the button? I have 3 buttons, and i need to programe every button on certain time for on and off (relay + bulb)
    button 1 : on 5sec , off 5 sec
    button 2: on 40 sec, off 10 sec
    button 3: on 1 minute ,off 1 minute

and when one is pressed ,start measuring evalute time(start my stopwatch (in hours)) , when button is pressed ?
2.I need to program that when reaches the certain value of light intensity during testing in lux, to stop the measurement and last measuring values will be on show on display and stay there until program is reseted ​​(time, temperature, number of on and offs,luxes)?
3. So I wanted to see the actual values ​​displayed both on the display and on the serial port?

Please help me :slight_smile:

In Add , I put my schematic project

my source codes that work:
[
#include <BH1750.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

long day = 86400000; // 86400000 milliseconds in a day
long hour = 3600000; // 3600000 milliseconds in an hour
long minute = 60000; // 60000 milliseconds in a minute
long second = 1000; // 1000 milliseconds in a second

BH1750 lightMeter;
long count = 0;
int rele = 8;
unsigned long time;
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 7

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // Set the LCD I2C address

void setup()
{
sensors.begin();
lcd.begin (20,4); // pre 20 x 4 LCD modul
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);

lcd.home ();
lcd.print("Vyber typ testu ");
delay(300);
lcd.clear();
pinMode(rele, OUTPUT);// connected to S terminal of Relay
}

void loop()
{
sensors.requestTemperatures(); // Send the command to get temperatures
float x=sensors.getTempCByIndex(0);
lcd.setCursor(0,0);
lcd.print(“T=”);
lcd.setCursor(9,0);
lcd.print((char)223);
lcd.setCursor(10,0);
lcd.print(“C”);
lcd.setCursor(3,0);
lcd.print(x);

lightMeter.begin();
uint16_t lux = lightMeter.readLightLevel();
lcd.setCursor(0,1);
lcd.print(“Int=” + (String)lux + " lux ");

digitalWrite(rele,HIGH);// turn relay ON
delay(5000);// keep it ON for 5 seconds

digitalWrite(rele, LOW);// turn relay OFF
delay(5000);// keep it OFF for 5 seconds

count ++;
lcd.setCursor(0,2);
lcd.print(“ZV=”);
lcd.setCursor(4,2);
lcd.print(count, DEC);
lcd.setCursor(0,3);
lcd.print("Cas: ");

;//prints time since program started
long timeNow = millis();
int days = timeNow / day ; //number of days
int hours = (timeNow % day) / hour; //the remainder from days division (in milliseconds) divided by hours, this gives the full hours
int minutes = ((timeNow % day) % hour) / minute ; //and so on…
int seconds = (((timeNow % day) % hour) % minute) / second;
lcd.setCursor(5,3);
lcd.print(hours);
}

]

Use code tags when showing your sketch, use the </> button in the posting menu.

Your switches need to be rewired.

which switches?? those tree switches??

The switches need to be wired as in the schematic, one of the 3 samples.

2017-08-05_20-33-24.jpg Click on the image for full resolution.

Like this?

No

As S1 and R4 in the schematic I posted.
Closing S1 would cause a HIGH on the pin (if that’s what you wanted).

Use S3 if you want a LOW on a push.

Now, put the resistors on the other side of the switches, terminal 2.

Do you want a HIGH or a LOW on a switch closer.

ok , HIGH i did that thanks, but how i programe to wait until i push button???

Is this right??

That way in the image, you should get a LOW normally, HIGH when the switch is closed.
You may have to rotate the switch 90° if this setup doesn’t work.

There is a sketch in the IDE examples that shows how to detect a change in switch position.
When a transition from LOW to HIGH is detected, you can do what’s needed …