Controlling a motor with a relay code


I’m new here, so as with arduino and coding. I’m trying to move a motor with a command in the serial monitor.
I’m reading a lot about this stuff, but it’s a lot to take in. I wrote this code, i really appreciate feedback please.

int arm=2;

void setup() {
pinMode(arm, OUTPUT);


void loop() {
arm == 2;
/*pinMode default HIGH to LOW
digitalWrite(arm, LOW);

Serial.println("Voer opdracht in… "); //Vraag
while(Serial.available()==0) {

arm = Serial.parseInt(); //Integer lezen
digitalWrite(arm, HIGH);


arm == 2;Oops

Please remember to use code tags when posting code

Oh okey, thank you!

But the code won't work. I can't control the motor on command in the serial monitor. Do you have suggestions?

You're inputting a pin number, and writing HIGH to that pin number, whether or not that pin is an output.

Is that a useful summary?

Yes i tried to write a basic script for 1 motor, but i've 4 motors attached to the relay. Using more pins on a arduino MEGA 2560. I'm hoping to learn to control 1 pin, with that knowledge expand to the rest.