Components Required:

  • Arduino Board
  • LED (light emitting diode)
  • Resistor 220ohm
  • Jumper Wire
  • Breadboard
  • Recommended Site


In this tutorial, we will learn how to connect Arduino to Processing.We will to communication using the Serial Port. We will use the Processing Development Environment to control the Arduino. This is the first the Processing tutorial. When we will press the left and right button the LED turn on and turn off.

Min Required:  30 min Required

Quick points:

  • we will use the processing development environment to control the Arduino.
  • processing is an open source programming language. it is a graphic based. so it’s ideal for electronic arts, new media art, and visual design.
  • Download the Processing: –



  1. We will attach the LED onto the breadboard.
  2. We will connect the220 ohm resistor’s one leg to the LED’s long leg.
  3. We will connect the resistor’s other leg to the digital pin 13.
  4. And last, we will connect the LED’s short leg to the GND.


const int ledPin = 13;    //define the LED pin

void setup(){

  pinMode(ledPin, OUTPUT);    //initialize LED output
  Serial.begin(9600);         //start the serial communication

void loop(){

  if(Serial.available() > 0){           //if some data is available of in the serial port
    char ledPinState =;   //read the value
    if(ledPinState == '1'){             //if statement will be true(1)
      digitalWrite(ledPin, HIGH);       //turn ON the LED
    if(ledPinState == '0'){             //if statement will be false(0)
      digitalWrite(ledPin, LOW);        //turn OFF the LED
Get the Processing Source Code:
import processing.serial.*;      //import the library for a serial communication (sketch-import library-serial)

Serial myPort;                  //define name of the serial communication

PImage bg;                      //add the background image.Declare variable "bg" of type PImage

void setup(){                   //we will set a resolution for the graphical window

  size(259, 194);               //set the image size 259 by 194 pixels
  bg=loadImage ("redLED.png");  //upload the image into the program
  //the image file must be in the data folder of the current sketch to load successfully

  myPort=new Serial(this, "COM6", 9600);  //se the name of our communication port (Arduino COM port)