merge two codes into one

I'm new in Arduino, and I need help to merge two codes into one for academic project.

check the attachment please.

Regards,

Dc_Motor.ino (376 Bytes)

arduino_LED_code.ino (637 Bytes)

For such tiny amounts of code, it's simpler and better if you just post your code.

/*
Adafruit Arduino - Lesson 13. DC Motor
*/
 
 
int motorPin = 11;
 
void setup() 
{ 
  pinMode(motorPin, OUTPUT);
  Serial.begin(9600);
  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);
    }
    }
  }
int led = 13; // Pin 13
     
void setup()
{
    pinMode(led, OUTPUT); // Set pin 13 as digital out
     
    // Start up serial connection
    Serial.begin(9600); // baud rate
   // Serial.flush();
}
     
void loop()
{
    String input = "";
     
    // Read any serial input
    while (Serial.available() > 0)
    {
        input += (char) Serial.read(); // Read in one char at a time
        delay(5); // Delay for 5 ms so the next char has time to be received
    }
     
    if (input == "on")
    {
        digitalWrite(led, HIGH); // on
    }
    else if (input == "off")
    {
        digitalWrite(led, LOW); // off
    }
}

PS You didn't actually say what the merged code should do.

What do you want the merged program to do and what have you tried ?

academic project.

Homework ?

It would have helped if you had read the two posts by Nick Gammon at the top of this forum and followed the advice given in them before posting the question.

Have a look at this Simple Merge Demo

...R