I noticed that numerous examples of a sketch to run the same project are offered by different brands. I have not compared all examples, but it occurred to me that if the comments were deleted in each example, the essential code is identical. I opened the SparkFun Tinker Kit Example sketch 02 in text editor and deleted everything that didn’t look to me like code. I understand // is for same-line comments, and /* - */ included all comments in between. Very interesting comments, but after reading and learning the lesson, no longer essential. Then I uploaded the resulting sketch. The file must have .ino extension, and reside in a folder, of course. The picture attached is a screen shot of the uploaded sketch. The example works as intended. The breadboard LED blinks faster and slower with a twist of the potentiometer knob. Can anyone experienced in actually writing original sketches tell me if I am on the right track?
If you only removed the comments then yes, it’s still the same program. Your screenshot seems like a legit program. But I don’t know what it was originally. Nothing is changed to the microcode put in the flash memory, as the c-preprocessor removes the comments before it is compiled to actual code.
The question is why on earth… would you want to make this a habit? Comments are meant to give explanations. To you when you review your code in the future. Or to others that have never seen your code before, why you chose those code statements to do what it does. It may seem obvious now, but in years time you might look at it again and although you might recognize the individual statements, but may not have a clue why or what it’s supposed to do. The comments are meant to give context or annotations to what the program is doing. Nobody has a perfect memory. Especially when you get into complex loops and conditional logic. But hey, feel free to give your future self some headaches.
Wiki on comments in regards to programming:
Thanks Valen for your reply. Sorry it was five days until I returned to the forum. The potentiometer tutorial is simple. The code with all the comments looks more complex than it is. The comment slash was the first code character I learned. Now, I have to figure out what the rest of the signs mean. Since last week, I completed the RGB LED tutorial #3. I will post a separate question about which values can be changed for different color patterns with the same breadboard set-up before I take it apart and go on to the next tutorial. See you around.