Connect Your Arduino With Processing





Introduction: Connect Your Arduino With Processing

Have you ever thought about...? Using Arduino with Processing? In this Instructable I show you the quick and easiest way to do this. Just keep reading!

Cover photo by jeanbaptisteparis:

Step 1: Step 1: Open Processing

The first step is opening the Processing program. This is the code:

import processing.serial.*;

Serial myPort; // Create a serial object for the usb port

void setup(){

size(600, 200);

String portName = Serial.list()[7]; //here is sometimes an error with the compilation. Try to change numbers until //you get the right one.

myPort = new Serial(this, portName, 9600);


void draw() {

if(mousePressed == true){ // if you press the mouse, then...

myPort.write('1'); //write one

println("1"); // print one


else{ // if not

myPort.write('0'); // write zero



Step 2: Step 2: Arduino


#include <Servo.h> // Servo library

Servo myservo; // Create a Servo object

char val; // Data received from the serial port

void setup() {

myservo.attach(7); // Where are you attaching your servo? You can change this number.

Serial.begin(9600); // Start serial comunication at 9600 bps


void loop(){

if(Serial.available()){ // If the serial port is available

val =; //Read the serial port


if(val == '1'){ // if you're getting one, then

myservo.write(180);} // move your servo 180º

else{ // if not

myservo.write(50); // move your servo 50º


delay(10); // wait 10 miliseconds for the next reading


Step 3: Schematics

Just connect your servo to Arduino as it's shown.




    • Epilog Challenge 9

      Epilog Challenge 9
    • Paper Contest 2018

      Paper Contest 2018
    • Pocket-Sized Contest

      Pocket-Sized Contest

    We have a be nice policy.
    Please be positive and constructive.




    Thank you for sharing !

    I will consider to develop some projects combining both worlds: Arduino & Processing.

    I'm glad you like it! You've very cool instructables, I'm amazed!