I have been writing code for a Morse code flasher. In on section of the code I have it so that the serial monitor will take a capital or lowercase letter. The problem is that it gives me an error of duplicate case value. Is it not possible to use or statements within a switch statement like this.
case
'a'|| 'A' :
Serial.println ('a');
dot();
dash();
letterspace();
break;
Mecatronicsstudent:
The problem is that it gives me an error of duplicate case value. Is it not possible to use or statements within a switch statement like this.
case
'a'|| 'A' :
Serial.println ('a');
dot();
dash();
letterspace();
break;
What you want to do is something like this
switch (var) {
case 'a':
case 'A':
//do something when var equals a/A
break;
case 'b':
case 'B':
//do something when var equals b/B
break;
default:
// if nothing else matches, do the default
// default is optional
}
Of course what you should really do is study the code that was posted in your other thread by liudr.