Duplicate case value

I keep getting the error for duplicate case value and I am not nearly at the level to know why can someone help me out?
the part where the error is in in red

int reststate; // Variable for Rest state
int stepstate; // Variable for Step state
int followstate; // Variable for Follow state
int blinkstate; // Variable for Blink state
int switchstate; // Variable for Switch state
int val;
#include <Servo.h>
Servo servo1;
int state = reststate;
void setup() {
Serial.begin(9600); // Start up
while(!Serial); // Wait until started up
Serial.println(“Input choose from (R S F W B) starting state is Rest”); // Ask for input we started from the Rest state
servo1.write(30); // move to 30


void loop() {
char L = Serial.read();
// als er input is, uitlezen
// als een state wissel nodig is wisselen

// gedrag van je state uitvoeren
if(state == reststate){
if(L == ‘S’){
state = ‘stepstate’;
else if(L ==‘B’){
state = ‘blinkstate’;}

else if(L ==‘F’){
state = ‘followstate’;}

else if(L ==‘W’){
state = ‘switchstate’;}

else if (L ==‘R’){
state = ‘reststate’;}

else if (state == ‘stepstate’){
else if (state == ‘followstate’){
else if (state == ‘blinkstate’){
else if (state == ‘switchstate’){

case ‘stepstate’:
servo1.write(30); // move to 30
delay(500); // wait 0.5 s
servo1.write(60); // move to 60
delay(500); // wait 0.5 s
case ‘followstate’:
val= analogRead(SENSORPIN); // read value of potentiometer
val= map(val, 0, 1023, 0, 180); //scale to use on servo
servo1.write(val); // move to position
delay (20);
// read the input on analog pin 0:
int sensorValue = analogRead(0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
case ‘blinkstate’:

case ‘switchstate’:

case ‘reststate’:


case 'stepstate':

You can't do that. There is no character called 'stepstate'

please use code tags.


enum STATE {reststate, stepstate, followstate, blinkstate, switchstate};
int state = reststate;

thanks for the reply,

but can you maybe say how i can make te code work? I dont know how to fix it and i dont have the know how

I amended my reply to add a hint while you were answering.
See how you get on with that.

the duplicate case value part is now solved, but now my system doesn't work eiter. do i need to chanche the if while part at the beginning of the void loop aswell now that i use enum?

I don't know, because I can't see your code. Don't forget the code tags - here, I've got a spare pair you can have: [code][/code]

Also, do Tools > Auto Format before you post your code, makes it easier for us to read and can also help you find bugs.

And when you say it doesn't work don't forget to tell us what it is supposed to do and how that differs from what it actually does.

A word of warning: char L = Serial.read(); 'L' will mostly have the value -1. You need to ensure that this doesn't matter to you, or make sure it doesn't happen by calling "Serial.available()" to make sure there's something to read, before you read it.