I am trying to setup PWM in my project but have been facing issues. In order to remove any hidden issues I have reduced my code the following but I am still seeing unwanted effects. When I setup the PWM the LED lights dimly as expected. But as soon as it enters the loop, the LED shuts off and flickers every 5 seconds. Why would the LED turn off when entering the loop?
Decided to test out one more theory to see it it was truly the loop that was shutting down the PWM. I updated the code to the following which results in the LED staying let for 5 seconds and staying off for 5.
They are two Elegoo's. But I think I have found the issue. I think the sketch might have been corrupted somehow. I created a brand new one and copied the code over and now everything is working as expected. Thank you guys for your help. I will need to port everything over to the new sketch.
If your harddisk or filesystem is corrupted, that would be really bad. You might want to check that with a disk scan, and perhaps also with a tool that checks the SMART information and can run the tests of the harddisk itself. Check if there is new firmware for you harddisk and if older firmware has issues.
Perhaps you could re-install the Arduino IDE.
Did you change the clock of the computer ? Perhaps that confused the Arduino compiling/build process.
Sometimes an Arduino board keeps resetting, therefor I often start by outputting a message:
Serial.println( "The sketch has started");
Sometimes I want to check if the upload really worked. Then I use this:
Thank you for the replies. As I think through it I’m suspecting it was due to a library I probably installed then deleted. Probably messed with the internal timers somehow. I’m new to all this but that’s what I could gather from searching the internet. Just a theory.