int input;
void setup() {
Serial.begin(34800);
}
void loop() {
if (Serial.available()) input = Serial.read();
if (input == 1) {
digitalWrite(1, HIGH);
digitalWrite(4, HIGH);
}
if (input == 2) {
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
}
}
Equality tests use '=='
Put curly brackets around instruction blocks (I supposed that the 2 digitalWrite were in the same block each time, which may not be the case)
I doubt the OP want's to check for 1 because I assume he uses the Serial monitor. So that would be '1'.
Because 'input' is only used in loop, there is no need for it to be global.
Note pin 1, 2, 3 and for are not set as output. So a digitalWrite() to HIGH will only turn on the internal pull up.
Maybe obvious, maybe not, not calling digitalWrite(pin, HIGH) will not magically turn an output LOW. You need to explicitly call digitalWrite(pin, LOW) for that to happen.
Less obvious (and not a problem here but might be when extended). The if() of the last character is called over and over if there is no new character in serial. No big deal because you only do a digitalWrite() call but get's weird if you only want stuff to happen once. Especially because it's probably marked by the fact you have set line ending to newline (and/or carriage return) in the Serial Monitor thus having a newline (or carriage return) char after every character.
Last but not least, take the help the compiler gives you. Use logical variable names (not just short ones!) to help you remember what everything is.
digitalWrite(LedPin, HIGH);
//is way more readable than
digitalWrite(2, HIGH);