Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Well you need to use the Serial.read() function for starters. Theres nowhere in your code where this functionality has been started, so its tough to help you any more without knowing exactly where youre stuck. Commented Feb 17 at 16:02
  • I cannot see a Serial.read() in your code, so I do not understand your problem. Serial.read() returns -1, if there's nothing to read yet. Returns a character code (e.g. 49 == '1' ), if there is. Commented Feb 17 at 16:05
  • 1
    start by removing all of the LED code ... focus only on the serial data part of the code ... write a program that reads the serial data, parses the data, and sends the parsed data to the serial monitor ... when that works as expected, then add the LED code Commented Feb 17 at 17:05
  • Assuming you will be hand-typing these instructions, keep in mind that we humans are much slower than the Arduino, and until you finish typing a command, the chip will have an incomplete command. Until it has been completed, parsing it will fail. You can test the first typed character and set that LED as you described, but you will see it light at 50%, and later change to it's final brightness once you finish typing that value. That may or may not be what you want it to do .... Commented Feb 18 at 13:11
  • To read the numeric value correctly, you'll need to collect multiple characters from the serial buffer until you detect a line ending (e.g., '\n') or a space. Commented Feb 18 at 16:27