Hi Everyone! I need a little help in writing some code for my project.
The idea is that I measure the total time that the light meter reads above (or is equal to) 1500 lux.
Context: a project for a wearable device that tracks the time you spend outdoors every day (above or equal to 1500 lux brightness detects that you must be outdoors)
So far I have approached this by saying that...
when the lux value is greater than or equal to 1500lux,
add 10 seconds (10,000ms) to a container "a" for ( total time outdoors)
the code does this check every 10 seconds
But there is a problem with the code and I don't know what's wrong,
specifically on the line I have coloured in red, it says "expected initialiser before "+" token" :
Code:
#include <BH1750.h> //Sensor Library
#include <Wire.h> //12C Library
BH1750 lightMeter;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Wire.begin();
lightMeter.begin();
uint16_t a =0; //a=total time outdoors in ms
int x =10000;
}
void loop() {
// put your main code here, to run repeatedly:
uint16_t lux = lightMeter.readLightLevel();
if (lightMeter.readLightLevel()>=1500){
uint16_t a+ int x;
//+10 seconds to total time
}
delay (10,000)//checks if you are outside every 10 seconds, if so it assumes that for those 10 seconds since the last check you have been outdoors and adds this on to total outdoor time