Need help combining codes

Arduino: 1.8.16 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\Jlo\Documents\Arduino\capston\capstonedraft\capstonedraft.ino: In function 'void loop()':

capstonedraft:51:13: error: 'Stop' was not declared in this scope

         Stop(); //Initialize with motors stoped.

         ^~~~

C:\Users\Jlo\Documents\Arduino\capston\capstonedraft\capstonedraft.ino:51:13: note: suggested alternative: 'loop'

         Stop(); //Initialize with motors stoped.

         ^~~~

         loop

capstonedraft:54:17: error: 'forward' was not declared in this scope

             forward();

             ^~~~~~~

C:\Users\Jlo\Documents\Arduino\capston\capstonedraft\capstonedraft.ino:54:17: note: suggested alternative: 'fread'

             forward();

             ^~~~~~~

             fread

capstonedraft:57:17: error: 'back' was not declared in this scope

             back();

             ^~~~

capstonedraft:60:17: error: 'left' was not declared in this scope

             left();

             ^~~~

capstonedraft:63:17: error: 'right' was not declared in this scope

             right();

             ^~~~~

capstonedraft:66:17: error: 'forwardleft' was not declared in this scope

             forwardleft();

             ^~~~~~~~~~~

capstonedraft:69:17: error: 'forwardright' was not declared in this scope

             forwardright();

             ^~~~~~~~~~~~

capstonedraft:72:17: error: 'backleft' was not declared in this scope

             backleft();

             ^~~~~~~~

capstonedraft:75:17: error: 'backright' was not declared in this scope

             backright();

             ^~~~~~~~~

capstonedraft:113:15: error: 'brakeOn' was not declared in this scope

           brakeOn();

           ^~~~~~~

C:\Users\Jlo\Documents\Arduino\capston\capstonedraft\capstonedraft.ino:113:15: note: suggested alternative: 'brakeTime'

           brakeOn();

           ^~~~~~~

           brakeTime

capstonedraft:117:15: error: 'brakeOff' was not declared in this scope

           brakeOff();

           ^~~~~~~~

C:\Users\Jlo\Documents\Arduino\capston\capstonedraft\capstonedraft.ino:117:15: note: suggested alternative: 'brkonoff'

           brakeOff();

           ^~~~~~~~

           brkonoff

capstonedraft:123:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:129:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:135:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:141:2: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:146:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:151:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:156:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:161:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:167:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:175:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:201:1: error: a function-definition is not allowed here before '{' token

{

^

capstonedraft:203:1: error: expected '}' at end of input

}

^

exit status 1

'Stop' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

#define in1 3 //L298n Motor Driver pins.
#define in2 10
#define in3 4
#define in4 5
#define LED 13

// l298n motor driver
int command; //Int to store app command state.
int Speed = 204; // 0 - 255.
int Speedsec;
int buttonState = 0;
int lastButtonState = 0;
int Turnradius = 0; //Set the radius of a turn, 0 - 255 Note:the robot will malfunction if this is higher than int Speed.
int brakeTime = 45;
int brkonoff = 1; //1 for the electronic braking system, 0 for normal.
//end

void setup()
{
//motor driver
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(LED, OUTPUT); //Set the LED pin.

}

void loop()

{
if (Serial.available() > 0)
{
command = Serial.read();
Stop(); //Initialize with motors stoped.
switch (command) {
case 'F':
forward();
break;

Your code seems incomplete

If that's all the code you have..
Go back and get the rest, you're missing quite a bit..
sorry.. ~q

can you help me combines these code because i keep getting a not declared error when i combine

code 1



#define in1 5 //L298n Motor Driver pins.
#define in2 6
#define in3 10
#define in4 11
#define LED 13
int command; //Int to store app command state.
int Speed = 204; // 0 - 255.
int Speedsec;
int buttonState = 0;
int lastButtonState = 0;
int Turnradius = 0; //Set the radius of a turn, 0 - 255 Note:the robot will malfunction if this is higher than int Speed.
int brakeTime = 45;
int brkonoff = 1; //1 for the electronic braking system, 0 for normal.
void setup() {
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(LED, OUTPUT); //Set the LED pin.
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
}

void loop() {
  if (Serial.available() > 0) {
    command = Serial.read();
    Stop(); //Initialize with motors stoped.
    switch (command) {
      case 'F':
        forward();
        break;
      case 'B':
        back();
        break;
      case 'L':
        left();
        break;
      case 'R':
        right();
        break;
      case 'G':
        forwardleft();
        break;
      case 'I':
        forwardright();
        break;
      case 'H':
        backleft();
        break;
      case 'J':
        backright();
        break;
      case '0':
        Speed = 100;
        break;
      case '1':
        Speed = 140;
        break;
      case '2':
        Speed = 153;
        break;
      case '3':
        Speed = 165;
        break;
      case '4':
        Speed = 178;
        break;
      case '5':
        Speed = 191;
        break;
      case '6':
        Speed = 204;
        break;
      case '7':
        Speed = 216;
        break;
      case '8':
        Speed = 229;
        break;
      case '9':
        Speed = 242;
        break;
      case 'q':
        Speed = 255;
        break;
    }
    Speedsec = Turnradius;
    if (brkonoff == 1) {
      brakeOn();
    } else {
      brakeOff();
    }
  }
}

void forward() {
  analogWrite(in1, Speed);
  analogWrite(in3, Speed);
}

void back() {
  analogWrite(in2, Speed);
  analogWrite(in4, Speed);
}

void left() {
  analogWrite(in3, Speed);
  analogWrite(in2, Speed);
}

void right() {
  analogWrite(in4, Speed);
  analogWrite(in1, Speed);
}
void forwardleft() {
  analogWrite(in1, Speedsec);
  analogWrite(in3, Speed);
}
void forwardright() {
  analogWrite(in1, Speed);
  analogWrite(in3, Speedsec);
}
void backright() {
  analogWrite(in2, Speed);
  analogWrite(in4, Speedsec);
}
void backleft() {
  analogWrite(in2, Speedsec);
  analogWrite(in4, Speed);
}

void Stop() {
  analogWrite(in1, 0);
  analogWrite(in2, 0);
  analogWrite(in3, 0);
  analogWrite(in4, 0);
}

void brakeOn() {
  //Here's the future use: an electronic braking system!
  // read the pushbutton input pin:
  buttonState = command;
  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == 'S') {
      if (lastButtonState != buttonState) {
        digitalWrite(in1, HIGH);
        digitalWrite(in2, HIGH);
        digitalWrite(in3, HIGH);
        digitalWrite(in4, HIGH);
        delay(brakeTime);
        Stop();
      }
    }
    // save the current state as the last state,
    //for next time through the loop
    lastButtonState = buttonState;
  }
}
void brakeOff() {

}

code2

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position
const int TrigPin = 8;
const int EchoPin = 9;
float cm;
float ft;

void setup()
 {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  
  pinMode(TrigPin, OUTPUT);
  pinMode(EchoPin, INPUT);
  Serial.begin(9600);
}

void loop() 
{
 

   for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay (50);                       // waits 15ms for the servo to reach the position
     
   // ultrasonic sensor
   
 }
 {
    delay (500); 
    digitalWrite(TrigPin, LOW);       
    delayMicroseconds(2);
    digitalWrite(TrigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(TrigPin, LOW);
    cm = pulseIn(EchoPin, HIGH) / 58.0; //The echo time is converted into cm
    cm = (int(cm * 100.0)) / 100.0;     //Keep two decimal places
    Serial.print("Distance\t=\t");
    Serial.print(cm);
    Serial.print("cm");
    Serial.println(); 
 } 
   for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(50);                       // waits 15ms for the servo to reach the position

    //ultrasonic sensor
  
  }
 {
    delay (500); 
 } 
  
    digitalWrite(TrigPin, LOW);       
    delayMicroseconds(2);
    digitalWrite(TrigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(TrigPin, LOW);
    cm = pulseIn(EchoPin, HIGH) / 58.0; //The echo time is converted into cm
    cm = (int(cm * 100.0)) / 100.0;     //Keep two decimal places
    Serial.print("Distance\t=\t");
    Serial.print(cm);
    Serial.print("cm");
    Serial.println(); 
  

}

thank you
1 Like

Please post your best attempt at combining the 2 sketches

Post an annotated schematic showing all connections, power, ground and power source. Also post links to technical information on each of the hardware devices.

There are, most likily, missing or misplaced curly brackets ({ }) in the code (at a minimum). But there is no way to help you unless you post the entire code. When you do post the code we will have to copy the code to a text editor for examination and/or the IDE to verify the code to try to fix the errors. If you, please, post the code properly in a code block (code tags) it will make it much easier for us to copy.

Use the IDE autoformat tool (ctrl-t or Tools, Auto format). That will often make the location of missing or misplaced brackets obvious.

If you read and follow the guidelines you will get faster and better help.

i just reattempted to combine them in a fresh sketch and no error
if inquire an error i will post on here again

i combined them but now my motor doesnt work it doest drive now but the code doest have an error

#define in1 3 //L298n Motor Driver pins.
#define in2 10
#define in3 4
#define in4 5
#define LED 13

//servo
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

//ultrasonic sensor
int pos = 0;    // variable to store the servo position
const int TrigPin = 8;
const int EchoPin = 9;
float cm;
float ft;

//l298 motor driver
int command; //Int to store app command state.
int Speed = 204; // 0 - 255.
int Speedsec;
int buttonState = 0;
int lastButtonState = 0;
int Turnradius = 0; //Set the radius of a turn, 0 - 255 Note:the robot will malfunction if this is higher than int Speed.
int brakeTime = 45;
int brkonoff = 1; //1 for the electronic braking system, 0 for normal.


void setup()
{
 //servo
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  
  //ultrasonic sensor
  pinMode(TrigPin, OUTPUT);
  pinMode(EchoPin, INPUT);
  Serial.begin(9600);

  //motor driver
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(LED, OUTPUT); //Set the LED pin.
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
}

void loop() 
{
    //servo
        for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
        // in steps of 1 degree
        myservo.write(pos);              // tell servo to go to position in variable 'pos'
        delay (50);                       // waits 15ms for the servo to reach the position
    
  }
   // ultrasonic sensor

  {
    delay (500); 
  
    digitalWrite(TrigPin, LOW);       
    delayMicroseconds(2);
    digitalWrite(TrigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(TrigPin, LOW);
    cm = pulseIn(EchoPin, HIGH) / 58.0; //The echo time is converted into cm
    cm = (int(cm * 100.0)) / 100.0;     //Keep two decimal places
    Serial.print("Distance\t=\t");
    Serial.print(cm);
    Serial.print("cm");
    Serial.println(); 

     }
     //servo 
   for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(50);                       // waits 15ms for the servo to reach the position

    //ultrasonic sensor
  
  }
 {
    delay (500); 
 } 
  
    digitalWrite(TrigPin, LOW);       
    delayMicroseconds(2);
    digitalWrite(TrigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(TrigPin, LOW);
    cm = pulseIn(EchoPin, HIGH) / 58.0; //The echo time is converted into cm
    cm = (int(cm * 100.0)) / 100.0;     //Keep two decimal places
    Serial.print("Distance\t=\t");
    Serial.print(cm);
    Serial.print("cm");
    Serial.println(); 
  


   //motor driver
  if (Serial.available() > 0) {
    command = Serial.read();
    Stop(); //Initialize with motors stoped.
    switch (command) {
      case 'F':
        forward();
        break;
      case 'B':
        back();
        break;
      case 'L':
        left();
        break;
      case 'R':
        right();
        break;
      case 'G':
        forwardleft();
        break;
      case 'I':
        forwardright();
        break;
      case 'H':
        backleft();
        break;
      case 'J':
        backright();
        break;
      case '0':
        Speed = 100;
        break;
      case '1':
        Speed = 140;
        break;
      case '2':
        Speed = 153;
        break;
      case '3':
        Speed = 165;
        break;
      case '4':
        Speed = 178;
        break;
      case '5':
        Speed = 191;
        break;
      case '6':
        Speed = 204;
        break;
      case '7':
        Speed = 216;
        break;
      case '8':
        Speed = 229;
        break;
      case '9':
        Speed = 242;
        break;
      case 'q':
        Speed = 255;
        break;
    }
    Speedsec = Turnradius;
    if (brkonoff == 1) {
      brakeOn();
    } else {
      brakeOff();
    }
  }
}

void forward() {
  analogWrite(in1, Speed);
  analogWrite(in3, Speed);
}

void back() {
  analogWrite(in2, Speed);
  analogWrite(in4, Speed);
}

void left() {
  analogWrite(in3, Speed);
  analogWrite(in2, Speed);
}

void right() {
  analogWrite(in4, Speed);
  analogWrite(in1, Speed);
}
void forwardleft() {
  analogWrite(in1, Speedsec);
  analogWrite(in3, Speed);
}
void forwardright() {
  analogWrite(in1, Speed);
  analogWrite(in3, Speedsec);
}
void backright() {
  analogWrite(in2, Speed);
  analogWrite(in4, Speedsec);
}
void backleft() {
  analogWrite(in2, Speedsec);
  analogWrite(in4, Speed);
}

void Stop() {
  analogWrite(in1, 0);
  analogWrite(in2, 0);
  analogWrite(in3, 0);
  analogWrite(in4, 0);
}

void brakeOn() {
  //Here's the future use: an electronic braking system!
  // read the pushbutton input pin:
  buttonState = command;
  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == 'S') {
      if (lastButtonState != buttonState) {
        digitalWrite(in1, HIGH);
        digitalWrite(in2, HIGH);
        digitalWrite(in3, HIGH);
        digitalWrite(in4, HIGH);
        delay(brakeTime);
        Stop();
      }
    }
    // save the current state as the last state,
    //for next time through the loop
    lastButtonState = buttonState;
  }
}
void brakeOff() {

}

i combine my code to one program and now it doesnt drive

the code combines a servo motor, ultrasonic sensor and l298n motor driver as well as bluetooth hc06
everthing work except the bluetooth to the phone to drive the motor , the bluetooth does connect just doesnt drive

#define in1 3 //L298n Motor Driver pins.
#define in2 10
#define in3 4
#define in4 5
#define LED 13

//servo
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

//ultrasonic sensor
int pos = 0;    // variable to store the servo position
const int TrigPin = 8;
const int EchoPin = 9;
float cm;
float ft;

//l298 motor driver
int command; //Int to store app command state.
int Speed = 204; // 0 - 255.
int Speedsec;
int buttonState = 0;
int lastButtonState = 0;
int Turnradius = 0; //Set the radius of a turn, 0 - 255 Note:the robot will malfunction if this is higher than int Speed.
int brakeTime = 45;
int brkonoff = 1; //1 for the electronic braking system, 0 for normal.


void setup()
{
 //servo
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  
  //ultrasonic sensor
  pinMode(TrigPin, OUTPUT);
  pinMode(EchoPin, INPUT);
  Serial.begin(9600);

  //motor driver
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(LED, OUTPUT); //Set the LED pin.
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
}

void loop() 
{
    //servo
        for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
        // in steps of 1 degree
        myservo.write(pos);              // tell servo to go to position in variable 'pos'
        delay (50);                       // waits 15ms for the servo to reach the position
    
  }
   // ultrasonic sensor

  {
    delay (500); 
  
    digitalWrite(TrigPin, LOW);       
    delayMicroseconds(2);
    digitalWrite(TrigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(TrigPin, LOW);
    cm = pulseIn(EchoPin, HIGH) / 58.0; //The echo time is converted into cm
    cm = (int(cm * 100.0)) / 100.0;     //Keep two decimal places
    Serial.print("Distance\t=\t");
    Serial.print(cm);
    Serial.print("cm");
    Serial.println(); 

     }
     //servo 
   for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(50);                       // waits 15ms for the servo to reach the position

    //ultrasonic sensor
  
  }
 {
    delay (500); 
 } 
  
    digitalWrite(TrigPin, LOW);       
    delayMicroseconds(2);
    digitalWrite(TrigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(TrigPin, LOW);
    cm = pulseIn(EchoPin, HIGH) / 58.0; //The echo time is converted into cm
    cm = (int(cm * 100.0)) / 100.0;     //Keep two decimal places
    Serial.print("Distance\t=\t");
    Serial.print(cm);
    Serial.print("cm");
    Serial.println(); 
  


   //motor driver
  if (Serial.available() > 0) {
    command = Serial.read();
    Stop(); //Initialize with motors stoped.
    switch (command) {
      case 'F':
        forward();
        break;
      case 'B':
        back();
        break;
      case 'L':
        left();
        break;
      case 'R':
        right();
        break;
      case 'G':
        forwardleft();
        break;
      case 'I':
        forwardright();
        break;
      case 'H':
        backleft();
        break;
      case 'J':
        backright();
        break;
      case '0':
        Speed = 100;
        break;
      case '1':
        Speed = 140;
        break;
      case '2':
        Speed = 153;
        break;
      case '3':
        Speed = 165;
        break;
      case '4':
        Speed = 178;
        break;
      case '5':
        Speed = 191;
        break;
      case '6':
        Speed = 204;
        break;
      case '7':
        Speed = 216;
        break;
      case '8':
        Speed = 229;
        break;
      case '9':
        Speed = 242;
        break;
      case 'q':
        Speed = 255;
        break;
    }
    Speedsec = Turnradius;
    if (brkonoff == 1) {
      brakeOn();
    } else {
      brakeOff();
    }
  }
}

void forward() {
  analogWrite(in1, Speed);
  analogWrite(in3, Speed);
}

void back() {
  analogWrite(in2, Speed);
  analogWrite(in4, Speed);
}

void left() {
  analogWrite(in3, Speed);
  analogWrite(in2, Speed);
}

void right() {
  analogWrite(in4, Speed);
  analogWrite(in1, Speed);
}
void forwardleft() {
  analogWrite(in1, Speedsec);
  analogWrite(in3, Speed);
}
void forwardright() {
  analogWrite(in1, Speed);
  analogWrite(in3, Speedsec);
}
void backright() {
  analogWrite(in2, Speed);
  analogWrite(in4, Speedsec);
}
void backleft() {
  analogWrite(in2, Speedsec);
  analogWrite(in4, Speed);
}

void Stop() {
  analogWrite(in1, 0);
  analogWrite(in2, 0);
  analogWrite(in3, 0);
  analogWrite(in4, 0);
}

void brakeOn() {
  //Here's the future use: an electronic braking system!
  // read the pushbutton input pin:
  buttonState = command;
  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == 'S') {
      if (lastButtonState != buttonState) {
        digitalWrite(in1, HIGH);
        digitalWrite(in2, HIGH);
        digitalWrite(in3, HIGH);
        digitalWrite(in4, HIGH);
        delay(brakeTime);
        Stop();
      }
    }
    // save the current state as the last state,
    //for next time through the loop
    lastButtonState = buttonState;
  }
}
void brakeOff() {

}

Does the test code for the servo work? What servo & how is it powered? Many "servo no work" issues are power related. Pictures of the wiring and a hand drawn schematic would be helpful please.

You don't mention what type of Arduino you have. Is it an UNO? Which one?

Can you show a diagram of how you have this wired and connected? What sort of power supply do you have for the motor?

Also here:

and here:

https://forum.arduino.cc/t/issue-with-code/1145924

OP seems to be starting multiple threads for the same code. Please do not do that. Just keep adding to the first thread you started.

doesn't the L298 have an enable pin?

while you could control a motor using the IN1/2 pins with the EN pin set HIGH, those pins would need to be connect to arduino PWM pins (looks like pin 4 is not a PWM pin).

when using the IN1/2 pins, one would be set LOW and the other controlled with a PWM signal using analogWrite().

both forward() and reverse() driver different IN1/IN2 pins, but they don't set the other pins to zero. shouldn't forward be

void forward() {
    analogWrite(in1, Speed);
    analogWrite(in3, Speed);
    analogWrite(in2,0);
    analogWrite(in4,0);
}

have you flagged it?

Yes. I flagged my post on this one and linked to the other two. Hopefully mods can figure it out from that.

I have merged your topics due to them having too much overlap on the same subject matter @larenzia93.

In the future, please only create one topic for each distinct subject matter and be careful not to cause them to converge into parallel discussions.

The reason is that generating multiple threads on the same subject matter can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Thanks in advance for your cooperation.

yes its not the servo its the l298 motor driver and bluetooth

yes but i have 2 jumpers on them


it works as is seperately

all codes work separately and they all have different pin

From the Servo library reference:

On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.

Having the Bluetooth module and serial monitor both connected to pins 0 and 1 may not work well. There should be only 1 thing connected to a serial port. I would suggest that you use a software serial port , on different pins than 0 & 1, for the Bluetooth module and save the hardware serial port for program upload and program output and debugging.