Check and correct based of sensor many sensors- logic structure

@jjlee32,

Looks like you are making progress, great news.

I have not used the elapsedMillis library but, generally timers use unsigned long types for their math which means they will roll over in about 47 days. There is a great post on this topic here. Generally this is not an issue and, if you write the code correctly, roll overs are not an issue thanks to the wonders of 2s complement math.

I have a few comments to consider as you keep working:

  • if a value is to be just true or false use the type bool (g?) - this saves space as int is a 32-bit number while bool is 1
  • Avoid #define if you can as it can have unexpected consequences if one of your libraries happens to use the same term. One convention is that #define terms are ALLCAPS. In your example you can use “const int FloatPinBottom = D3;” instead
  • If you are going to use Serial.print(), you need to add Serial.begin(9600); to your Setup()
  • Again, I am not familiar with elapsedMillis but, I would expect you would need to reset the timers before or after you use them.

I hope this helps, and good luck with your continued progress.

Chip

1 Like