In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
For one thing, the integer match around line 46 may do funny things and certainly never produce anything with decimals.
Maybe start by posting a clear schematic of your setup and a good photo that shows how everything is connected. Then upload the full code of your sketch as text, not as an image.
Finally, be aware of the possibilities and limitations of 'pulseIn'. I think you may want to look at the use of timers and the input capture functionality they offer.
Definitely a good idea. Calling pulseIn() twice does not capture from the same PWM cycle which introduces jitter. The Nano Every has a timer mode that is able to do so.
See 21.3.3.1.6 Input Capture Frequency and Pulse-Width Measurement Mode in the CPU data sheet.
Moreover, there will be unanticipated behavior depending on when the function is called; if you do this at some point halfway during a PWM cycle, you'll just get bogus data. It really only works if you start counting immediately after the rising/falling slope - in which case a Timer-based approach or perhaps even something using a pin change interrupt will work just as well, or even better.
After measuring the PWM signal with a multimeter at the Nano every also had some bad signals. Turns out the plug wasn't making a good connection. Now my measurements are the same on the Nano every as well as on the multimeter.