Introduction: Connect Your Arduino With Processing

About: I'm a teenager girl who loves Arduino, science and music. I make Arduino projects, rock albums and experiments.

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.