LED switchcase isn't responding properly

I have tried multiple different ways to get this project to work and this is only step 1. I have attached my code. I am using the correct com port COM4, when I upload everything complies correctly, but when given input to the serial Monitor the arduino uno I am using doesn’t respond properly. ON should turn lights on, and OFF should turn them off, but the lights are either on all the time or won’t turn on at all. I have my input as 2 and have tried switching through the inputs to be able to get any result and the only thing that works is pin 13, but I am trying other pins because of my project is going to be using a set of two pins to make a flashing light.

Also, I read through a lot of the FAQs and and other forum posts so I feel like where I am supposed to post.

Thank you

sketch_apr13a.ino (389 Bytes)

It wouldn't allow me to attach this to my first post. This is the picture of the setup I am doing for my project.

Since when is 'ON' or 'OFF' a single character?

Aka, you can't compare it like that / use a switch() like that.

Try for example:

//no need for byte
//made the variable name more descriptive
const byte LedPin = 8;

void setup() {
  // put your setup code here, to run once:

  pinMode(LedPin, OUTPUT);

void loop() {
  //only read if there is something to read
    char data = Serial.read();
    //and really check for a char
      case 'N': 
        digitalWrite(LedPin, HIGH);
      case 'F':
        digitalWrite(LedPin, LOW);

Please also use code tags next time. See "How to use the forum" for that (and more).

It wouldn’t allow me to attach this to my first post. This is the picture of the setup I am doing for my project.

No picture.

You need to go and read the forum instructions so that you can mark up your code and insert it using the “</>” icon in the posting window.

In fact, the IDE has a “copy for forum” link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But don’t forget to use the “Auto-Format” (Ctrl-T) option first to make it easy to read. If you do not post it as “code” it can as you now see, be quite garbled and is always more difficult to read.

It is inappropriate to attach it as a “.ino” file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only between functional blocks.