Hi Guys,
I have a project that I am working on that has 10 shift registers...
The issue I am having is that I need to be able to send characters via serial to turn pins on and off.
the code below is what I have working, but instead of for example, case 'a' or case 'b' I need the unit to wait for more than 1 character before acting. this will enable me to have more than 255 options....
Can someone please help me. not sure what way to go here....
void loop(){
if (Serial.available() > 0) {
int inByte = Serial.read();
// do something different depending on the character received.
// The switch statement expects single number values for each case;
// in this example, though, you're using single quotes to tell
// the controller to get the ASCII value for the character. For
// example 'a' = 97, 'b' = 98, and so forth:
switch (inByte) {
case 'a':
setRegisterPin(0, HIGH);
writeRegisters();
break;
case 'b':
setRegisterPin(1, HIGH);
writeRegisters();
break;
the below will not compile... but here is what I would like for example....
void loop(){
if (Serial.available() > 0) {
int inByte = Serial.read();
// do something different depending on the character received.
// The switch statement expects single number values for each case;
// in this exmaple, though, you're using single quotes to tell
// the controller to get the ASCII value for the character. For
// example 'a' = 97, 'b' = 98, and so forth:
switch (inByte) {
case '!0301':
setRegisterPin(0, HIGH);
writeRegisters();
break;
case '!0401':
setRegisterPin(0, LOW);
writeRegisters();
break;
case '!0302':
setRegisterPin(1, HIGH);
writeRegisters();
break;
case '!0402':
setRegisterPin(1, LOW);
writeRegisters();
break;