switched computer and now my code is not working

My arduino uno was connected to a laptop with windows 10 and with the following code i could press a key on my keyboard in the serial monitor and the relay would close a circuit. Now i switched to a new computer and installed the latest version of arduino on my new laptop (windows 10) but the relay does not close a circuit any more. The main LED in it is turned on, and pressing a key on my keyboard only causes a quick flashing in the vcc LED.

int inByte = 0;  // initialize the variable inByte
void setup() {
  // put your setup code here, to run once:

  pinMode(7, OUTPUT); //turn on the led bulb port
  Serial.begin(9600); //
  digitalWrite(7, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0) { // check if any data received
    inByte = Serial.read(); // yes, so read it from incoming buffer
    if (inByte == '1') {
      digitalWrite(7, HIGH);
    }
    else {
      digitalWrite(7, LOW);
    }
  }
}

What am I missing?

Thank you

how were you sending the keys from the computer to the arduino? in the Serial Monitor?

did you set the baud rate to 9600? are you sending CR and LF also at the same time ? (should be set to none other with you send the '1' and the relay/whatever is on pin7 goes HIGH but right after you get CR and LF and the will go LOW)


Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

Thanks for your response.
I edited my post.

I indeed set the baud to 9600 in the serial monitor.

I didn't do anything about CR LF (honestly I don't know what they are)- what you see is what I did and once i switched computers it stopped working.

How can I fix this?

Thanks

Shahar

Set CRLF popup to none (end of line / line-ending)

Of course you need to ensure you’ve selected the right Serial port

As it turns out the problem was with the laptop.
Thank you for your help nonetheless.