repeating problems in arduino (C++) code
Go to solution
Solved by SpaceNugget,
Lets say you have a function called day() and it returns the day. if you have:
string a = day();
and its tuesday, a holds the value "tuesday". tomorrow a will still hold the value "tuesday" but day() will return "wednesday"
so when you write:
int moisture = analogRead(Moist);
moisture then equals the result of the function analogRead() exactly when that line is executed.
look through your program to see how many times you call moisture = analogRead(moist);
Only once, so you only have a single reading of the moisture. so every loop when you have:
- float M1 = 1023 - moisture;
- float M2 = M1 / 10;
- float M3 = 100 - M2-22;
moisture still equals the same thing from before, so M3 never changes.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now