Serial Communication with Arduino

Last Updated on March 24, 2024

Here this project shows how to communicate with arduino serial terminal? For an application we have chosen four LEDs to indicate direction.

In a bread board four LEDs are placed in different direction and the Arduino sketch composed to control those LEDs with computer numeric key by pressing particular key we can get output.

This Arduino code can be modified to get desired input and output.


Circuit diagram


Arduino serial communication sketch code

//Serial communication to arduino board through key board to control direction Indicators
const int right = 12;
const int left = 9;
const int top = 10;
const int bottom = 11;
char data;

void setup() {
  pinMode(right, OUTPUT);
  pinMode(left, OUTPUT);
  pinMode(top, OUTPUT);
  pinMode(bottom, OUTPUT);

void loop() {
  if (Serial.available() > 0) {
    data =;
    if (data == '1') {
      digitalWrite(left, HIGH);
      digitalWrite(right, LOW);
      digitalWrite(top, LOW);
      digitalWrite(bottom, LOW);
      Serial.println("Left Indicator activated");
    } else if (data == '2') {
      digitalWrite(left, LOW);
      digitalWrite(right, LOW);
      digitalWrite(top, HIGH);
      digitalWrite(bottom, LOW);
      Serial.println("Top Indicator activated");
    } else if (data == '3') {
      digitalWrite(left, LOW);
      digitalWrite(right, LOW);
      digitalWrite(top, LOW);
      digitalWrite(bottom, HIGH);
      Serial.println("Bottom Indicator activated");
    } else if (data == '4') {
      digitalWrite(left, LOW);
      digitalWrite(right, HIGH);
      digitalWrite(top, LOW);
      digitalWrite(bottom, LOW);
      Serial.println("Right Indicator activated");

Components List

1.Arduino uno1
4.Connecting wiresas required



Screen shot


Leave a Reply

Your email address will not be published. Required fields are marked *