Controlling DC motor via USB

Hello! I’m trying to control two DC motors with arduino uno via USB with Blynk virtual buttons.
The code I use for controlling motor without Blynk is:
int motorPin = 5;

void setup() 
  pinMode(motorPin, OUTPUT);
  while (! Serial);
  Serial.println("Speed 0 to 255");
void loop() 
  if (Serial.available())
    int speed = Serial.parseInt();
    if (speed >= 0 && speed <= 255)
      analogWrite(motorPin, speed);

Now, I tried and tried to make a code that will work with Blynk based on this code but without success. Any ideas?

As per the Welcome Topic… perhaps search this forum BEFORE asking a basic question. Searching for keywords like motor, car, robot, rover, etc. will show you lots of others questions, code, examples and solutions…

Then your coding methods will need to change a bit for Blynk usage (No major code in the void loop(), use timers instead). Start off with simple examples in the Sketch Builder and learn to walk before you drive :stuck_out_tongue_winking_eye:

Then as you read others topics, the Help Center & Documents, and start learning how it all works… you can ask specific Blynk questions about your motor project here in your topic.