Arduino + processing not working

All the code is uploaded but its not working please help.

You'll have to provide just a little more information here. ;)

Ok I have a Duemilanove with atmega 328. I think the pocessing cant find where the arduino is located.

What are you trying to do with processing? Do you have a program written in processing that talks to the Arduino? What code is on the Arduino? What do you expect the code to do, and what is it doing instead?

I am trying to do an ocilliscope.

The processing code is

 * Oscilloscope
 * Scope and logic analyzer to visualize volage on arduino digital and analog pins
 * (c) 2009 David Konsumer <>
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <>.

lots of ideas from:

logic analyzer mode that shows 1's and 0's clearly.
pause frame
save frame
configuarable pin-count
use as many pins as will fit on screen (tested with 12 at 800x800, seems ok)
use scope class in your own thing, easy to reuse, and setup any kind of GUI

data is formatted by LF char, and scope nums are seperated by " "


// TODO: add zooming
// TODO: detect things like SPI and i2C, label graph

import processing.serial.*;
import controlP5.*;

// how many scopes, you decide.
Scope[] scopes = new Scope[8];

Serial port;
ControlP5 controlP5;

PFont fontLarge;
PFont fontSmall;

int LINE_FEED=10; 

int[] vals;

void setup() 
  // put whatever you like, for size, in here
  // pick a neat multiple of scope count for height to amke it line up
  size(800, 800, P2D);
  controlP5 = new ControlP5(this);
  // set these up under tools/create font
  fontLarge = loadFont("TrebuchetMS-20.vlw");
  fontSmall = loadFont("Uni0554-8.vlw");
  int[] dimv = new int[2];
  dimv[0] = width-130; // 130 margin for text
  dimv[1] = height/scopes.length;
  // setup vals from serial
  vals = new int[scopes.length];
  for (int i=0;i<scopes.length;i++){
    int[] posv = new int[2];

    // random color, that will look nice and be visible
    scopes[i] = new Scope(posv, dimv, color((int)random(255), (int)random(127)+127, 255));
  port = new Serial(this, Serial.list()[0], 9600);
  // clear and wait for linefeed

void draw()
  // int[] vals = getTestValuesSquare();
  for (int i=0;i<scopes.length;i++){
    // update and draw scopes
    // conversion multiplier for voltage
    float multiplier = scopes[i].multiplier/scopes[i].resolution;
    // convert arduino vals to voltage
    float minval = scopes[i].minval * multiplier;
    float maxval = scopes[i].maxval * multiplier;
    float pinval =  scopes[i].values[scopes[i].values.length-1] * multiplier;
    // add lines
    line(0, scopes[i].pos[1], width, scopes[i].pos[1]);
    // add labels
    text(pinval, width-60, scopes[i].pos[1]+scopes[i].dim[1]-10);
    text("min: "+minval, scopes[i].dim[0]+10, scopes[i].pos[1]+40);
    text("max: "+maxval, scopes[i].dim[0]+10, scopes[i].pos[1]+48);
    text("pin: "+i, scopes[i].dim[0]+10,scopes[i].pos[1]+scopes[i].dim[1]-10);
  // draw text seperator
  line(scopes[0].dim[0], 0, scopes[0].dim[0],height);
  // update buttons

// handles button clicks
void controlEvent(ControlEvent theEvent) {
  int id = theEvent.controller().id();
  // button families are in chunks of 50 to avoid collisions
  if (id < 50){
  }else if (id < 100){
  }else if(id < 150){
    String fname = "data"+(id-100)+".csv";
    println("Saved as "+fname);

// handle serial data
void serialEvent(Serial p) { 
  String data = p.readStringUntil(LINE_FEED);
  if (data != null) {
    int[] vals = int(split(data, ' '));

// for test data, you can comment, if not using
int d=0;
ControlTimer ct = new ControlTimer();

int[] getTestValuesSin(){
  int[] vals = new int[scopes.length];
  // this is test data
  if (d==45){
  int sval = (int) abs(sin(d*2)*1023.0f);
  for (int i=0;i<scopes.length;i++){
  return vals;

int oldtime;
int time;
boolean up=false;

int[] getTestValuesSquare(){
  int[] vals = new int[scopes.length];
  time = ct.second();  
  if (oldtime==time){
    up = !up;
  for (int i=0;i<scopes.length;i++){
    if (up){
  return vals;

class Scope{
  int[] pos; // x, y start position
  int[] dim; // w, h dimensions
  color c; // color for lines
  color bounds_color=color(30); // color for center line
  color[] logic_colors; // size 2 color array for 0/1, red/green by default
  int[] values; // all values in the graph
  float resolution = 1024.0f; // max number that be displayed
  float multiplier = 5f; // the voltage multiplier
  int minval;
  int maxval;
  boolean logic = false; // use colors to show 0/1?
  boolean pause = false; // freeze input?
  posv is position (x,y)
  dimv is dimensions (w,h)
  cv is color for line
  Scope(int[] posv, int[] dimv, color cv){
    pos = posv;
    dim = dimv;
    c = cv;
    values = new int[dim[0]];
    // red and green defaults for logic colors
    logic_colors = new color[2];
    // I set this high here, so it will be overidden, with first smaller value:
    minval = (int)resolution;
  void draw(){
    if (!logic){
    for (int x=1; x<dim[0]; x++) {
      if (logic){
        if (values[x] > (resolution/2)){
        line(pos[0] + dim[0]-x-2,   pos[1], 
             pos[0] + dim[0]-x-2, pos[1] + dim[1]);
        line(pos[0] + dim[0]-x, pos[1] + dim[1]-getY(values[x-1])-1, 
             pos[0] + dim[0]-x, pos[1] + dim[1]-getY(values[x])-1);
  // draw center line
  void drawBounds(){
    line(pos[0],pos[1]+(dim[1]/2), dim[0], pos[1]+(dim[1]/2));
  // add a single point
  void addData(int val){
    if (!pause){
      for (int i=0; i<dim[0]-1; i++){
        values[i] = values[i+1];
      values[dim[0]-1] = val;
      if (val < minval){
        minval = val;
      if (val > maxval){
  // save current frame
  void saveData(String filename){
    String[] lines = new String[values.length];
    for (int i = 0; i < values.length; i++) {
      lines[i] = "" + values[i];
    saveStrings(filename, lines);
  private int getY(int val){
    return (int)(val / resolution * dim[1]) - 1;
Here is the arduino code

holds temp vals
int val;

void setup() {
// set 2-12 digital pins to read mode
for (int i=2;i<14;i++){
pinMode(i, INPUT);


void loop() {
// read all analog ports, split by " "
for (int i=0;i<6;i++){
Serial.print(" ");

// read all digital ports, split by " "
for (int i=2;i<14;i++){
Serial.print(" ");

// frame is marked by LF

well first change the serial.list[0] in your processing code to whatever com port your arduino is on. Make sure it looks like this with quotes left in: "COM 5" . Next, your arduino is set up for 115200 serial and processing is set up for 9600 serial. you have to pick the same one on both ends. You cant always copy code and expect it to work perfectly on your system. Take a little time and read the code to understand what its doing

This is not my code but thanks!!! :P

I seem to have same problem as kellykel. I found same "arduinoscope" code, but can't get it working...

I have chanced the serial port, checked the arduino sketch with arduino serial monitor & with a processing sketch I wrote. When I run the arduinoscope sketch in processing it starts ok, but doesn't show any graphs. The tx-led in arduino, shows that the board is sending data, but somehow I don't get in to the processing.

Also when testing the arduino sketch with photoresistor it gives proper values.

The arduinoscope sketch is a bit advanced for me, but it would help me with my project. Any ideas, how to continue...

You have the exact same problem, good.

I don't know about good ;), but have you got the system working?

I have identified the problem to serial data flow. For some reason the data arduino is sending is not read by processing. I can get the arduinoscope sketch print the available ports by adjusting it a bit, but not to print the values send from arduino. Other sketches I wrote will print the values in processing window. I didn't mention before that I have windows vista - anyway it has never before been a problem with arduino and processing.

Man we are twins, pocessing worked before with arduino but not with the scope. I even have vista. :'(

I was able to contact he maker of the sketch. It didn't took many hours before I got the answer. Now there is a fixed sketch for processing. Here is the address:

I just chanced the serial port to right one and it works! ;D ;D

This should help you kellykel too

Unfortunatey it stil doesn't work. The processing says that "controlP5" does not exist. :'(

Ok that's simple

dowload a control IP 5 library here:

It a .zip which you open and copy in libraries folder in your sketchbook folder for processing. Your oscilloscope should also be in sketchbook.

The sketch might also ask for some fonts, which you'll find here:

Put the font-files inside arduinoscope processing sketch folder . There is propably smarter way to do this processing's tool's -> create font -tool, but this one works too

Try again, it should work.

Thanks it works!!!!!!!!!!!!!!!! ;D :D ;) :)