Hi,
I am new to electronics in general and very, very new to programming. I followed a guide to make a cpu fan controller using an arduino and a temperature sensor. i got it working, but i want to get the rpms to display on the LED matrix of the uno r4 wifi arduino. I'm not sure what to even look up for this. Here is the fan control and led scrolling text code I'm using:
The delay() is blocking (as well as your "millis" code). If the blocking the sketch for 1 second suit you - you can easily replace your millis to the line delay(1000)
Clearly I need to start with basic 101, lol. I found a thread of someone explaining code blocking and I am having a hard time wrapping my head around that... I think I'll go check out that learn code section now, haha.
Okay I changed the code in the original post to just have delay(1000), idk if I need a blocking code there, but I'll keep the delay until I have a deeper understanding of coding in general.
This variable should be declared volatile because it is updated by an interrupt function and read in loop().
It's not safe to simply use count like that because it could get updated, by the interrupt function, part-way through reading it's value. You need to protect against that happening. You also need to set count to zero at some point, otherwise the RPM will keep going up!
I don't think think you necessarily need to remove the blocking code, but what you will need to do is accurately measure the time over which count has been increasing, using millis() or micros(). Currently your code is assuming that will be 1000ms, but you don't know how long those other statements take to execute.