This is generally what will happen when you test your sensors, especially for your IR and colour-detection sensors.
Most of us will fail the “works on 2nd try step”. And many of you will get incredibly tilted when the number of times you re-collected your data approaches infinity.
Yes - this is the biggest headache in this course - tuning your code to fit the ‘experimental’ data you get from the sensors.
There are ways to engineer around this weird inconsistency. Three guidelines for you!
1. Keep the sensor characteristics constant
Changing the positioning of the LED and LDR or IR sensors will drastically affect the data you collect. This is why Prof keeps emphasizing on “shielding” and neat wiring.
If you don’t do this, you will be cursed to be stuck in the infinite loop of testing and tilting.
2. Store data and collect often
Don’t throw away your data! Store the values you get from each testing ‘experiment’.
Try and vary the environment you are testing your data in (slightly darker room, another table in DSA lab) to ensure that your values are consistent-ish! If it’s not, you did something wrong in step 1.
3. Plot. Your. Data.
If you did guideline 1 and 2 properly, then this guideline will make it 10000% clear how to correctly program your sensor logic and I can personally guarantee you that from that, your colour-detection logic will work 100% of the time1.
Use your high school statistics knowledge and plot some graphs! Maybe something like {Red, green, blue} values VS the values of your data point(s). Experiment! Would a scatter, bar, or box plot work best?
You don’t need Excel to plot your graphs.
Use ANY tool that you are comfortable with. Plot your data appropriately, and you will be able to see a very clear pattern between each colour and exploit it. The more datasets you include in your data, the stronger the pattern (hence guideline 2).
If done correctly, you can precisely define correct logical bounds and equalities for your sensor logic. That was my experience when I took this course.
As an added bonus, if you do it right, you can include very nice graphs in your final report which will help your explanations AND make your report sedaps 👌
All the best and happy debugging!
-
Assuming the shielding and wiring doesn’t suddenly fail… ↩︎