samedi 6 juin 2020

interprets commands received from PC to control microcontroller LEDs

I am not sure how to code a function that will interpret the commands received from a PC. The syntax of the commands is as follows: leds -1+4~3+2

the first 5 characters of the command must always be 'leds '. a digit means the corresponding LED number (1-4). A leading plus (+) means that this LED is turned on, a minus (–) that it is turned off, and a tilde (~) means that the LED is toggled once.

i know how to define if a led is turned on/off in an individual statement, but i dont know how to create some kind of loop or something where the program reads the number and leading sign and knows which led that corresponds to and what state to put it in

the code should be in c.

Aucun commentaire:

Enregistrer un commentaire