arduino-examples
arduino-examples copied to clipboard
the content of the example file ReadASCIIString.ino feels odd to me.
file: examples/04.Communication/ReadASCIIString/ReadASCIIString.ino ` /* ... It parses them into ints, and uses those to fade an RGB LED. Circuit: Common-Cathode RGB LED wired like so:
-
red anode: digital pin 3 through 220 ohm resistor
-
green anode: digital pin 5 through 220 ohm resistor
-
blue anode: digital pin 6 through 220 ohm resistor
-
cathode: GND ...
if (Serial.read() == '\n') { // constrain the values to 0 - 255 and invert // if you're using a common-cathode LED, just use "constrain(color, 0, 255);" red = 255 - constrain(red, 0, 255); green = 255 - constrain(green, 0, 255); blue = 255 - constrain(blue, 0, 255); ... " `
the implementation of this example file feels odd to me. i mean the circuit wiring instruction part in the starting comment describes using a Common-Cathode RGB LED, i think people would assume the actual code implementation will be using a Common-Cathode RGB LED as well, but no, the code is actually for a Common-Anode RGB LED, plus the prior comment line confirms the starting comment. don't you feel odd about this? i think we should be consistent comments and code. (at least for me, this took some time to fully figure out the logic of the flow and understand what was going on... idk, maybe it's just me being dumb... :p )