This was definitely way harder, and I had to look online for advice. I finally found some code and a way to get things wired up, but it was doing all kinds of things "the easy way," which really confused me because it was hiding the math - I kept thinking, what is this loop() or constrain() function??? (Spoiler: they adjust a range of numbers from one scale to another, which I feel much better just doing myself.)
The code is in the model as well as the layout, but my intention had been to get the photoresistor working, then the thermal sensor, then the potentiometer again, and then pull everything together as suggested in the challenge.
These are the critical lines of the code:
lightLevel = analogRead(sensorPin);
Serial.println("OG lightLevel");
Serial.println(lightLevel);
lightLevel = (lightLevel - low)/range * 255;
where
int lightLevel, low = 54, high = 974;
are declared as global constants.
Since I don't have a photoresistor, I'm going to play around and see if I can come up with another idea for an extension, but I at least wanted to get this attempt documented in case I find one later!

No comments:
Post a Comment