Particle photon the best board i ever worked on. I have controlled devices and motor for a robot using some of the command like command.substring(); but dont know what exactly doing. Can any one please explaint me how it is working.
int ledControl(String command) {
int state =0;
int pinNumber = (command.charAt(1)-'0') - 1;
if(pinNumber < 0 || pinNumber > 7) return -1;
if(command.substring(3,7) == "HIGH") state = 1;
else if(command.substring(3,6) == "LOW") state = 0;
else return -2;
digitalWrite(pinNumber,state);
return 1;
}
Thank you in advance please help.