<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with #error - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23error</link>
      <pubDate>Sun, 08 Aug 2021 21:07:25 +0000</pubDate>
         <description>Tagged with #error - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23error/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Trouble connecting Android Mode 4.0 to Sdk</title>
      <link>https://forum.processing.org/two/discussion/25654/trouble-connecting-android-mode-4-0-to-sdk</link>
      <pubDate>Wed, 20 Dec 2017 17:10:06 +0000</pubDate>
      <dc:creator>crinta</dc:creator>
      <guid isPermaLink="false">25654@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I had an old version of Android Mode working fine, but when I upgraded to 4.0, Processing could get set up with the Android Sdk.  I am using Processing version 3.3.6.</p>

<ul>
<li>I installed API 26 and its build tools</li>
<li>I followed the steps on [<a href="https://forum.processing.org/one/topic/android-problems.html]" target="_blank" rel="nofollow">https://forum.processing.org/one/topic/android-problems.html]</a>(this forum page) including setting environment variables and updating JDK</li>
<li>When I manually changed preferences.txt to have android.sdk.path=[my path], Processing complains "Processing found an Android SDK, but is not valid. It could be missing some files, or might not be including the required platform for API 26."</li>
<li>Otherwise, it simply complains "Processing did not find an Android SDK on this computer."</li>
<li>If I locate the path manually it says the SDK could not be loaded</li>
<li>I even tried "Download SDK automatically".  The download finished, and Processing said the SDK could not be loaded.  I tried locating the SDK manually to where Processing had just downloaded it, and got the same error</li>
</ul>

<p>I took a look at [<a href="https://forum.processing.org/two/discussion/12665/android-sdk-could-not-be-loaded]" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/12665/android-sdk-could-not-be-loaded]</a>(this post), but nothing there seemed to help.</p>

<p>Surely, there is something I am missing.  Can anyone identify what I am doing wrong?  Thank you very much in advance!</p>
]]></description>
   </item>
   <item>
      <title>How to copy Java error message from red error bar in Processing 3?</title>
      <link>https://forum.processing.org/two/discussion/24250/how-to-copy-java-error-message-from-red-error-bar-in-processing-3</link>
      <pubDate>Mon, 25 Sep 2017 15:25:49 +0000</pubDate>
      <dc:creator>sdaau</dc:creator>
      <guid isPermaLink="false">24250@/two/discussions</guid>
      <description><![CDATA[<p>Say I have something like this:</p>

<p><img src="https://i.stack.imgur.com/Ym96q.png" alt="scrproc3" /></p>

<p>How do I copy the error message in red (the <code>Error on "VariableDeclarators"</code>) here?</p>

<p>Of course, here the error is trivial, but my actual use case is imported Java classes that are missing, and I'm not even getting the full error message written out... Also, it would be great to be able to copy and paste the error text elsewhere.</p>

<p>I've tried the obvious - holding the mouse pointer over the red area and hitting Ctrl-C, nothing happens...</p>

<p>Thanks in advance for your help!</p>
]]></description>
   </item>
   <item>
      <title>Error</title>
      <link>https://forum.processing.org/two/discussion/16873/error</link>
      <pubDate>Sun, 29 May 2016 08:19:23 +0000</pubDate>
      <dc:creator>martango</dc:creator>
      <guid isPermaLink="false">16873@/two/discussions</guid>
      <description><![CDATA[<h1>A fatal error has been detected by the Java Runtime Environment:</h1>

<p>#</p>

<h1>Internal Error (0x20474343), pid=5356, tid=5980</h1>

<p>#</p>

<h1>JRE version: Java(TM) SE Runtime Environment (8.0_74-b02) (build 1.8.0_74-b02)</h1>

<h1>Java VM: Java HotSpot(TM) 64-Bit Server VM (25.74-b02 mixed mode windows-amd64 compressed oops)</h1>

<h1>Problematic frame:</h1>

<h1>C  [KERNELBASE.dll+0x1a06d]</h1>

<p>#</p>

<h1>Failed to write core dump. Minidumps are not enabled by default on client versions of Windows</h1>

<p>#</p>

<h1>An error report file with more information is saved as:</h1>

<h1>C:\Users\SMY\Downloads\processing-3.0.2-windows64\processing-3.0.2\hs_err_pid5356.log</h1>

<p>#</p>

<h1>If you would like to submit a bug report, please visit:</h1>

<h1><a href="http://bugreport.java.com/bugreport/crash.jsp" target="_blank" rel="nofollow">http://bugreport.java.com/bugreport/crash.jsp</a></h1>

<h1>The crash happened outside the Java Virtual Machine in native code.</h1>

<h1>See problematic frame for where to report the bug.</h1>

<p>#
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.</p>

<p>i've some problems like that and i dont know why.  What is the problem guys ? can anywone tell me ?</p>
]]></description>
   </item>
   <item>
      <title>Error when attempting to run Processing 2.0 or 3.0</title>
      <link>https://forum.processing.org/two/discussion/13026/error-when-attempting-to-run-processing-2-0-or-3-0</link>
      <pubDate>Thu, 15 Oct 2015 01:05:53 +0000</pubDate>
      <dc:creator>SimonJ</dc:creator>
      <guid isPermaLink="false">13026@/two/discussions</guid>
      <description><![CDATA[<p><img src="http://forum.processing.org/two/uploads/imageupload/315/QBET6J8IWAR2.png" alt="processing error" title="processing error" /></p>

<p>This is the error I am given every time I attempt to open processing of any version
I have also uninstalled my java and reinstalled, don't know if that would have help
Just wondering if something else might be the problem as I am unable to find any solution</p>
]]></description>
   </item>
   <item>
      <title>Why is the Sound library not working?</title>
      <link>https://forum.processing.org/two/discussion/12777/why-is-the-sound-library-not-working</link>
      <pubDate>Fri, 02 Oct 2015 01:10:02 +0000</pubDate>
      <dc:creator>dawnspectraa</dc:creator>
      <guid isPermaLink="false">12777@/two/discussions</guid>
      <description><![CDATA[<p>P3 here.</p>

<p>I tried using the Sound library but gave me the error "This library may not me properly installed", blah, blah, 64bits, blah...</p>

<p>I had the same error with the video one, but moving the folder to C:\ (I mean, with only english ASCII characters, no ñ or á), it worked. Now I don't know what the heck is going on with the Sound one :/</p>
]]></description>
   </item>
   <item>
      <title>processing error at startup</title>
      <link>https://forum.processing.org/two/discussion/12492/processing-error-at-startup</link>
      <pubDate>Sun, 13 Sep 2015 07:28:54 +0000</pubDate>
      <dc:creator>flecheria</dc:creator>
      <guid isPermaLink="false">12492@/two/discussions</guid>
      <description><![CDATA[<p>Hi
when I open processing it gives me this error:</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/533/Q48TUCK1WVH5.jpg" alt="processing_error" title="processing_error" />
It happens with Processing 2 and 3. I tryed to reinstall java, cancel Processing preference, check java path. Nothing.
I thing that is something concerning my system a not a processing bug.
Do you have some hints about it?
Thanks</p>
]]></description>
   </item>
   <item>
      <title>Cam-input JMyron error !!</title>
      <link>https://forum.processing.org/two/discussion/3367/cam-input-jmyron-error</link>
      <pubDate>Fri, 28 Feb 2014 12:51:56 +0000</pubDate>
      <dc:creator>emndeniz</dc:creator>
      <guid isPermaLink="false">3367@/two/discussions</guid>
      <description><![CDATA[<p>I want to built a sentry gun which detect motion. I find some basic codes for it but whenever i want to run the codes in processing it gives error from JMyron library. I try to run codes from in Processing 2.2.1 and Processing 1.5.1. Processing says that 'C:\Users\emn\Documents\Processing\libraries\JMyron\library\JMyron.dll: Can't find dependent libraries' and processing 2.2.1 says that 'A library used by  this sketch is not installed properly.A library relies on native code that's not available.' . But i copy the libraries in C:\Users\emn\Documents\Processing\libraries. I am new at Prcocessing program. Can anyone help me or give a suggestions?</p>
]]></description>
   </item>
   <item>
      <title>nothing happens - mouseX problem?</title>
      <link>https://forum.processing.org/two/discussion/11431/nothing-happens-mousex-problem</link>
      <pubDate>Wed, 24 Jun 2015 10:15:25 +0000</pubDate>
      <dc:creator>joesh</dc:creator>
      <guid isPermaLink="false">11431@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm rather surprised that for some reason I can't get some examples in Dan Shiffman's Processing book to work. As an example this works:</p>

<p><code>void draw(){
  background(204);
  line(mouseX, 20, mouseY, 80);
}</code></p>

<p>however, this doesn't:</p>

<p><code>if (mouseX &lt; width/2) {
  background (255);
} else {
  background (0);
}</code></p>

<p>Can anyone explain what's happening (or not). I did some of these examples a year ago and I'm sure they worked then???</p>

<p>Maybe I need to debug, but I don't know how (as yet) being a newbie.</p>

<p>Thanks in advance - Joe</p>
]]></description>
   </item>
   <item>
      <title>minim library</title>
      <link>https://forum.processing.org/two/discussion/11393/minim-library</link>
      <pubDate>Sun, 21 Jun 2015 15:06:02 +0000</pubDate>
      <dc:creator>arduidiot</dc:creator>
      <guid isPermaLink="false">11393@/two/discussions</guid>
      <description><![CDATA[<p>has anyone ever encountered this error when using the minim library?</p>

<p>==== JavaSound Minim Error ====
==== Error acquiring TargetDataLine: line with format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian not supported.</p>
]]></description>
   </item>
   <item>
      <title>Syntax error, maybe missing right parenthesis?</title>
      <link>https://forum.processing.org/two/discussion/11207/syntax-error-maybe-missing-right-parenthesis</link>
      <pubDate>Sun, 07 Jun 2015 23:41:51 +0000</pubDate>
      <dc:creator>lolnyancats</dc:creator>
      <guid isPermaLink="false">11207@/two/discussions</guid>
      <description><![CDATA[<pre><code>ArrayList&lt;Cell&gt; cells;
  cells=new ArrayList&lt;Cell&gt;();
  for (int i=0; i&lt;900; i++) {
    cells.add(new Cell(i, i-hheight, 15, (q, 0, 0), 100, 50));
  }

class Cell {
  private int x, int y, int speed, color c, int wwidth, int hheight;
  Cell(int xpos, int ypos, int speedy, color col, int widthh, int heightt) {
    x=xpos;
    y=ypos;
    speed=speedy;
    c=col;
    wwidth=widthh;
    hheight=heightt;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>integrating PS3 Eye cam for motion detection</title>
      <link>https://forum.processing.org/two/discussion/10492/integrating-ps3-eye-cam-for-motion-detection</link>
      <pubDate>Fri, 24 Apr 2015 14:59:32 +0000</pubDate>
      <dc:creator>JulieG</dc:creator>
      <guid isPermaLink="false">10492@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I managed to get my first code to work (written on Processing 2.1.1): it detects motion via my mac built-in webcam, and applies a reverse-explode effect on an image. Here's the initial code:</p>

<pre lang="java">

//

import processing.video.*;
Capture video;
PImage prevFrame;
PImage img;       // The source image
int cellsize = 2; // Dimensions of each cell in the grid
int columns, rows;   // Number of columns and rows in our system
int largeur,hauteur,largeurInit,hauteurInit,echelle=1,nbPixelsBlancs=0,nbPixelsNoirs=0,saut=10;
float threshold = 10;


//----------------------------------------------------------

void setup() {
  
  
  frameRate(80);
    video = new Capture(this, 640, 480, 80);
  prevFrame = createImage(video.width,video.height,RGB);
  
  size(1000, 562, P3D);
  img = loadImage("fougeres.jpg");  // Load the image
  columns = img.width / cellsize;  // Calculate # of columns
  rows = img.height / cellsize;  // Calculate # of rows
}

//----------------------------------------------------------

void draw() {
    
  // Capture video
  if (video.available()) {
    // Save previous frame for motion detection!!
    prevFrame.copy(video,0,0,video.width,video.height,0,0,video.width,video.height); // Before we read the new frame, we always save the previous frame for comparison!
    prevFrame.updatePixels();
    video.read();
  }
  
  //loadPixels();
  video.loadPixels();
  prevFrame.loadPixels();
 nbPixelsBlancs=0;
  nbPixelsNoirs=0;
 
  
  for (int a = 0; a &lt; video.width; a ++ ) {
    for (int c = 0; c &lt; video.height; c ++ ) {
     
      int loc = a + c*video.width;            // Step 1, what is the 1D pixel location
      color current = video.pixels[loc];      // Step 2, what is the current color
      color previous = prevFrame.pixels[loc]; // Step 3, what is the previous color
     
      // Step 4, compare colors (previous vs. current)
      float r1 = red(current); float g1 = green(current); float b1 = blue(current);
      float r2 = red(previous); float g2 = green(previous); float b2 = blue(previous);
      float diff = dist(r1,g1,b1,r2,g2,b2);
     
      // Step 5, How different are the colors?
      // If the color at that pixel has changed, then there is motion at that pixel.
      if (diff &gt; threshold) {
        // If motion, display black
        //pixels[loc] = color(0);
        nbPixelsNoirs=nbPixelsNoirs+1;
       
      } else {
        // If not, display white
        //pixels[loc] = color(255);
        nbPixelsBlancs=nbPixelsBlancs+1;

      }
    }
  }
   
//----------------------------------------------------------
   
    background(0);

// Begin loop for columns

  
   for ( int i = 0; i &lt; columns; i++) {
    // Begin loop for rows
    for ( int j = 0; j &lt; rows; j++) {
      
      int x = i*cellsize + cellsize/2 ;  // x position
      int y = j*cellsize + cellsize/2 ;  // y position
      int loc = x + y*img.width;  // Pixel array location
      color c = img.pixels[loc];  // Grab the color
     
        // Calculate a z position as a function of mouseX and pixel brightness
      float z = (nbPixelsBlancs / (float(width)) * brightness(img.pixels[loc])/-800);
      float w = (nbPixelsBlancs / (float(width)) * brightness(img.pixels[loc])/-5000);
      
      // Translate to the location, set fill and stroke, and draw the rect
    
     pushMatrix(); 
     translate(x, y, z+w);
     fill(c, 204);
      noStroke();
      rectMode(CENTER);
      rect(0, 0, cellsize, cellsize);
      
     popMatrix();
       
  
    }
   }
 }
 
</pre>

<p>Here's my problem: I don't want it to work with my built-in webcam, but with a PS3 EYE cam.</p>

<p>Apparently, PS3 EYE only works on Processing 1.5.1, so I tried opening the code above in this version, changing the name of my video source to:</p>

<pre lang="java">
video = new Capture(this, width, height, "Sony HD Eye for PS3 (SLEH 00201)", 1000);
</pre>

<p>as according to tricks I found there: <a href="https://processing.org/discourse/beta/num_1251903672.html" target="_blank" rel="nofollow">https://processing.org/discourse/beta/num_1251903672.html</a></p>

<p>But I receive: "Error while setting up Capture"</p>

<p>I've tried several things, nothing does seem to work… Can someone help me? Maybe a fresh look on it would help…
Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Expecting EOF found if error</title>
      <link>https://forum.processing.org/two/discussion/9912/expecting-eof-found-if-error</link>
      <pubDate>Tue, 17 Mar 2015 21:28:13 +0000</pubDate>
      <dc:creator>darthliam</dc:creator>
      <guid isPermaLink="false">9912@/two/discussions</guid>
      <description><![CDATA[<p>Hello. I know that there are many other posts relating to this but I couldn't find a helpful one for my problem. It is supposed to make a chart displaying data from the Arduino, but it returns this error instead. Expecting EOF found if</p>

<p>It occurs on line 306. 306 is the very top line ( Below )</p>

<pre><code> if (inString != null) {
  // trim off any whitespace:
  inString = trim(inString);
  int[] rawValues = int(split(inString, ","));
  for (int i=0; i&lt;numOfSensors; i++) {
    sensorValues[i] = rawValues[i];
    //sensorValues[i] = map(rawValues[i], 0, 100, 0, 1);
  }
}
</code></pre>

<p>The rest of the code is below:</p>

<p>I am not publishing to the web.</p>

<pre><code>/* ==================================================== 

 GardenBot - computer module, local-connection sub-module

 beta version 2 (2011-01)
 written by Andrew Frueh
 <a href="http://gardenbot.org/" target="_blank" rel="nofollow">http://gardenbot.org/</a>

 This is the code for the local-connection sub-module of the computer module of GardenBot.
 This code should be run in the Processing environment (www.processing.org).
 This code communicates with the brain module (Arduino) and can record the data to a text file and/or the web.

 ==================================================== */



// ============================================================
// Here can setup the basic things you will need to change to be specific to your GardenBot setup

String dataFileName = "sensorData.csv";

// This is the header for the data file
String[] fileDataTemplate = {
  "y-m-d_hr:mn,moisture level (50-100mm),temperature 1,light level 1,waterIsOn)", 
  "MIN VALUES,0,0,0,0", 
  "MAX VALUES,1023,100,1023,1" // no comma on last item
};
/*
// List any URL that you want this script to report to
 String[] listOfURLs = {
 "<a href="http://127.0.0.1/gardenbot/caseStudy/charts/convertSensorData.php" target="_blank" rel="nofollow">http://127.0.0.1/gardenbot/caseStudy/charts/convertSensorData.php</a>",
 "<a href="http://gardenbot.org/caseStudy/charts/convertSensorData.php" target="_blank" rel="nofollow">http://gardenbot.org/caseStudy/charts/convertSensorData.php</a>",
 "<a href="http://127.0.0.1/GardenBotCharts/convertSensorData.php" target="_blank" rel="nofollow">http://127.0.0.1/GardenBotCharts/convertSensorData.php</a>" // no comma on last item
 };
 */



// ============================================================
// Initialize the variables

// to enable serial comunication

import processing.serial.*;


int stageMax = 600;
int stageWidth = stageMax;
int stageHeight = stageMax/2;
int numOfSensors = 4;
int[] sensorValues = new int[numOfSensors];
Serial myPort;

int sensorHistMarker = 0;
String[] sensorHistory = new String[1];
String[] sensorHistoryTrimmed = new String[1];
String[] URLexternalList = new String[1];


// messenging
long messageTimerFreq = 60000;//60,000 = 1 min
long logicTimerFreq = 900000;//900,000 = 15 min
long currentTime, messageTimerLast, logicTimerLast;

//
PFont fontA;



// ============================================================
// this is a standard Processing function, it happens once on start up

void setup() {
  size(stageWidth, stageHeight);
  background(#ffffff);


  // List all the available serial ports
  println(Serial.list());

  // load the data
  sensorHistory = loadStrings(dataFileName);

  // get the URL(s) provided in an external file
  //listOfURLs = loadStrings("listOfURLs.txt");

  // if the file does not exist, then create it and initialize it with the header
  if (sensorHistory==null || sensorHistory.length==0) {
    //sensorHistory[0] = append(sensorHistory, null);
    //
    saveStrings(dataFileName, fileDataTemplate); 
    // reload
    sensorHistory = loadStrings(dataFileName);
  }


  // write the data out to the files
  sendDataOut();

  println("sensorHistory[]: ");
  println(sensorHistory);
  println("STARTUP::  "+year()+"-"+month()+"-"+day()+"_"+hour()+":"+minute()+":"+second());
  // 


  myPort = new Serial(this, Serial.list()[2], 9600);
  // don't generate a serialEvent() unless you get a newline character:
  myPort.bufferUntil('\n');

  // load the font for drawing
  fontA = loadFont("CourierNewPS-BoldMT-48.vlw");
  textAlign(CENTER);
  // Set the font and its size (in units of pixels)
  textFont(fontA, 16);
  /*
  */
}




// ============================================================
// this is a standard Processing function - it happens over and over again
//   note: draw() is equivalent to loop() on Arduino
// 

void draw() {

  // for all timers
  currentTime = millis();

  if ( abs(currentTime - messageTimerLast) &gt;= messageTimerFreq) {
    messageTimerLast = currentTime;
    //
    // 82 = 'R'; for Report levels
    myPort.write(82);
  }


  if ( abs(currentTime - logicTimerLast) &gt;= logicTimerFreq) {
    logicTimerLast = currentTime;
    //

    /*
    // load data if not already
     if(sensorFileData==null){
     sensorFileData = loadStrings(dataFileName);
     }
     */

    /*
    //int y = year(), m = month(), d = day(), hr = hour(), mn = minute(), sc = second();
     String timeStamp = year()+"-"+month()+"-"+day()+"_"+hour()+":"+minute();
     int moistureLevel1 = sensorValues[0];
     int temperature1 = sensorValues[1];
     int lightLevel1 = sensorValues[2];
     int waterIsOn = sensorValues[3];
     int moistureLevel2 = sensorValues[4];
     String stringTemp = timeStamp+","+moistureLevel1+","+temperature1+","+lightLevel1+","+waterIsOn+","+moistureLevel2;
     */

    String stringTemp = "";
    stringTemp += year()+"-"+month()+"-"+day()+"_"+hour()+":"+minute();
    stringTemp += ",";
    stringTemp += sensorValues[0]; // MS1
    stringTemp += ",";
    stringTemp += sensorValues[1]; // TP1
    stringTemp += ",";
    stringTemp += sensorValues[2]; // LI1
    stringTemp += ",";
    stringTemp += sensorValues[3]; // WIO

    println(stringTemp);

    //sensorHistory[sensorHistMarker] = stringTemp;
    if (sensorHistory[0]==null) {
      sensorHistory[0] = stringTemp;
    } else {
      sensorHistory = append(sensorHistory, stringTemp);
    }
    sensorHistMarker++;

    // send data
    sendDataOut();
  }


  // &gt;&gt; draw the display
  //

  // draw the text
  int titlePosY = 20;
  int barTitlePosY = 50;

  fill(#222222);
  text("GardenBot - local communication sub-module", stageWidth/2, titlePosY);

  //int numOfBars = 3;
  int padding = round(stageWidth*.1);
  //float barWidth = (stageWidth/numOfBars)-(padding*(1+1/float(numOfBars)));
  int barWidth = int(stageWidth * .20);
  int barHeight = stageHeight-(padding*2);
  int i;
  float xTemp;
  float hTemp;
  // draw the bars

  // rect(x, y, width, height)
  // moisture sensor
  i = 0;
  xTemp = padding+(barWidth*i)+(padding*i);
  hTemp = barHeight*map(sensorValues[i], 0, 1023, 0, 1);
  fill(#aaaaaa);
  rect(xTemp, padding+(barHeight-hTemp), barWidth, padding+barHeight);
  fill(#555555);
  rect(xTemp, padding, barWidth, barHeight-hTemp);
  //
  fill(#222222);
  text("moisture", xTemp+(barWidth/2), barTitlePosY);

  // temp sensor
  i = 1;
  xTemp = padding+(barWidth*i)+(padding*i);
  hTemp = barHeight*map(sensorValues[i], 0, 1023, 0, 1);
  fill(#aaaaaa);
  rect(xTemp, padding+(barHeight-hTemp), barWidth, padding+barHeight);
  fill(#555555);
  rect(xTemp, padding, barWidth, barHeight-hTemp);
  //
  fill(#222222);
  text("temp", xTemp+(barWidth/2), barTitlePosY);

  // light sensor
  i = 2;
  xTemp = padding+(barWidth*i)+(padding*i);
  hTemp = barHeight*map(sensorValues[i], 0, 1023, 0, 1);
  fill(#aaaaaa);
  rect(xTemp, padding+(barHeight-hTemp), barWidth, padding+barHeight);
  fill(#555555);
  rect(xTemp, padding, barWidth, barHeight-hTemp);
  //
  fill(#222222);
  text("light", xTemp+(barWidth/2), barTitlePosY);


  /*
  int i;
   for(i=0;i&lt;numOfBars;i=i+1) {   
   float xTemp = padding+(barWidth*i)+(padding*i);
   float hTemp = barHeight*map(sensorValues[i],0,1023,0,1);
   fill(#aaaaff);
   rect(xTemp, padding+(barHeight-hTemp), barWidth, padding+barHeight);
   fill(#aa5500);
   rect(xTemp, padding, barWidth, barHeight-hTemp);
   }
   */
  // &lt;&lt; draw the display
}




// ============================================================
// this function sends the data out to a file and to the web

void sendDataOut() {

  // &gt;&gt; trim data
  String[] sensorHistoryHEAD = subset(sensorHistory, 0, 3);
  String[] sensorHistoryDATA = subset(sensorHistory, 3);
  // figure out the index of where to start reading the data
  int position = sensorHistoryDATA.length - 288; // 3 days worth = 288
  // aquire only the last x days worth of data
  sensorHistoryDATA = subset(sensorHistoryDATA, position);
  // splice the arrays back together
  sensorHistoryTrimmed = splice(sensorHistoryHEAD, sensorHistoryDATA, 3);
  // &lt;&lt; trim data



  // write data to the file, full data
  saveStrings(dataFileName, sensorHistory);
  /*   
   if(listOfURLs.length &gt; 0){
   // create a string for sending as POST var
   String srtTemp = join(sensorHistoryTrimmed,"\n");
   //
   for(int i=0; i&lt;listOfURLs.length; i++){
   // save data to the web 
   postNewItem(listOfURLs[i],"sensorData="+srtTemp);
   } 
   } */
}




// ============================================================
// this function catches a serial event when the Arduino board responds


// get the ASCII string:
// String inString = myPort.readStringUntil('\n');  
String inString = p.readStringUntil('\n');

 if (inString != null) {
  // trim off any whitespace:
  inString = trim(inString);
  int[] rawValues = int(split(inString, ","));
  for (int i=0; i&lt;numOfSensors; i++) {
    sensorValues[i] = rawValues[i];
    //sensorValues[i] = map(rawValues[i], 0, 100, 0, 1);
  }
}





// ============================================================
// 
// &gt;&gt; postNewItem()
//
// this function thanks to: Euskadi - from the Processing forum (pulled 2010-06-15)
// <a href="http://processing.org/discourse/yabb/YaBB.cgi?board=Integrate;action=display;num=1090838754" target="_blank" rel="nofollow">http://processing.org/discourse/yabb/YaBB.cgi?board=Integrate;action=display;num=1090838754</a>
/*
void postNewItem (String urlIN, String message) {  
 try {  

 URL      url;  
 URLConnection urlConn;  
 DataOutputStream   dos;  
 DataInputStream    dis;  

 url = new URL(urlIN);  
 urlConn = url.openConnection();  
 urlConn.setDoInput(true);  
 urlConn.setDoOutput(true);  
 urlConn.setUseCaches(false);  
 urlConn.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");  

 dos = new DataOutputStream (urlConn.getOutputStream());  

 dos.writeBytes(message);  
 dos.flush();  
 dos.close();  

 // the server responds by saying  
 // "SUCCESS" or "FAILURE"  
 dis = new DataInputStream(urlConn.getInputStream());  
 String s = dis.readLine();  
 dis.close();  

/*
 if (s.equals("SUCCESS")) {  
 //toDoList.addItem(addTextField.getText());  
 ;//addTextField.setText("");  
 } else {  
 ; //addTextField.setText("Post Error!");  
 }  
 */
/* 
 } // end of "try"  

 catch (MalformedURLException mue) {  
 ; //addTextField.setText("mue error");  
 }  
 catch (IOException ioe) {  
 ; //addTextField.setText("IO Exception");  
 }  

 }  
 // &lt;&lt; postNewItem()
 */
</code></pre>
]]></description>
   </item>
   <item>
      <title>cannot convert from AudioSample to AudioSample (minim)</title>
      <link>https://forum.processing.org/two/discussion/9804/cannot-convert-from-audiosample-to-audiosample-minim</link>
      <pubDate>Wed, 11 Mar 2015 01:21:11 +0000</pubDate>
      <dc:creator>feroz1996</dc:creator>
      <guid isPermaLink="false">9804@/two/discussions</guid>
      <description><![CDATA[<p>Hey all,</p>

<p>I was trying to use minim in one of my other projects and was running into issues so I made this very simple program to test things out... I get a "cannot convert from AudioSample to AudioSample" error..? This seems to be the exact implementation from the examples at: <a rel="nofollow" href="http://code.compartmental.net/minim/audiosample_class_audiosample.html">http://code.compartmental.net/minim/audiosample_class_audiosample.html</a>.</p>

<pre><code>import ddf.minim.*;
Minim minim;
AudioSample sample;
AudioPlayer player;

void setup(){
  minim = new Minim(this);
  minim.debugOn();
  sample = minim.loadSample("tamb.wav");
  //player = minim.loadFile("tamb.wav");
}
void draw(){

}
void mouseClicked(){
  sample.trigger();
  //player.play();
  //player.rewind();
}
</code></pre>

<p>When that didn't work I tried loading the same wav file, a &lt;1 second tamborine sample if that matters, into AudioPlayer (commented sections of code above). It seemed to load in ok but when I tried to play it I got a Java.lang.ArrayIndexOutOfBoundsException: 15</p>

<p>minim debug (before playing):</p>

<pre><code>==== JavaSound Minim Debug ====
==== Base input stream is: java.io.FileInputStream@257b746

==== JavaSound Minim Debug ====
==== Acquired AudioInputStream.
==== It is -1 frames long.
==== Marking support: true

==== JavaSound Minim Debug ====
==== Reading from class javax.sound.sampled.AudioInputStream

==== JavaSound Minim Debug ====
==== File format is: MPEG1L1 48000.0 Hz, unknown bits per sample, mono, unknown frame size, 125.0 frames/second, 

==== JavaSound Minim Debug ====
==== SourceDataLine is class com.sun.media.sound.DirectAudioDevice$DirectSDL
==== Buffer size is 8192 bytes.
==== Format is PCM_SIGNED 48000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian.

==== JavaSound Minim Debug ====
==== Getting the properties.

==== JavaSound Minim Debug ====
==== MpegAudioFileReader.getAudioFileFormat(InputStream inputStream, long mediaLength): begin

==== JavaSound Minim Debug ====
==== InputStream : java.io.FileInputStream@fca1255 =&gt;RIFF@&amp;WAVEJUNK\

==== JavaSound Minim Debug ====
==== RIFF/WAV stream found

==== JavaSound Minim Debug ====
==== File properties: {mp3.crc=false, mp3.copyright=true, mp3.padding=true, mp3.channels=1, mp3.version.mpeg=1, mp3.length.bytes=403016, mp3.framerate.fps=125.0, mp3.framesize.bytes=320, duration=9976000, mp3.version.layer=1, mp3.length.frames=1247, mp3.frequency.hz=48000, mp3.header.pos=0, mp3.vbr.scale=0, mp3.bitrate.nominal.bps=320000, mp3.version.encoding=MPEG1L1, mp3.mode=3, mp3.vbr=false, mp3.original=true}

==== JavaSound Minim Debug ====
==== JSBaseAudioRecordingStream :: FloatSampleBuffer has 1024 samples.

==== JavaSound Minim Debug ====
==== JSBaseAudioRecordingStream :: rawBytes has length 2048

==== JavaSound Minim Debug ====
==== JSBaseAudioRecordingStream :: skipBytes has length 960000

==== JavaSound Minim Debug ====
==== SourceDataLine is class com.sun.media.sound.DirectAudioDevice$DirectSDL
==== Buffer size is 8192 bytes.
==== Format is PCM_SIGNED 48000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian.

=== Minim Debug ===
=== Likely buffer underrun in AudioOutput. 
</code></pre>

<p>After trying to play:</p>

<pre><code>    java.lang.ArrayIndexOutOfBoundsException: 15
        at javazoom.jl.decoder.LayerIDecoder$SubbandLayer1.read_allocation(Unknown Source)
        at javazoom.jl.decoder.LayerIDecoder.readAllocation(Unknown Source)
        at javazoom.jl.decoder.LayerIDecoder.decodeFrame(Unknown Source)
        at javazoom.jl.decoder.Decoder.decodeFrame(Unknown Source)
        at javazoom.spi.mpeg.sampled.convert.DecodedMpegAudioInputStream.execute(Unknown Source)
        at org.tritonus.share.TCircularBuffer.read(TCircularBuffer.java:134)
        at org.tritonus.share.sampled.convert.TAsynchronousFilteredAudioInputStream.read(TAsynchronousFilteredAudioInputStream.java:189)
        at ddf.minim.javasound.JSBaseAudioRecordingStream.readBytes(Unknown Source)
        at ddf.minim.javasound.JSBaseAudioRecordingStream.mRead(Unknown Source)
        at ddf.minim.javasound.JSBaseAudioRecordingStream.read(Unknown Source)
        at ddf.minim.javasound.JSAudioOutput.readStream(Unknown Source)
        at ddf.minim.javasound.JSAudioOutput.run(Unknown Source)
</code></pre>

<p>The file in question: <a rel="nofollow" href="https://www.dropbox.com/s/a37o9qzvgqhzh5v/tamb.wav?dl=0">https://www.dropbox.com/s/a37o9qzvgqhzh5v/tamb.wav?dl=0</a></p>

<p>Does anyone see anything wrong?</p>
]]></description>
   </item>
   <item>
      <title>Issue with a lab</title>
      <link>https://forum.processing.org/two/discussion/9613/issue-with-a-lab</link>
      <pubDate>Fri, 27 Feb 2015 16:22:54 +0000</pubDate>
      <dc:creator>lolnyancats</dc:creator>
      <guid isPermaLink="false">9613@/two/discussions</guid>
      <description><![CDATA[<pre><code>      int num =5;  
      int sumd = sum(num);
      println(“The sum of the digits is ”  + sumd);

      int sum(int n)
      {
      int ctr;
      int sd=0;
      if (n &lt;=0)
      sd = n;
      else
      {
      for(ctr = 1; ctr &lt;= n; ctr++)
      sd += ctr;
      }
      return (sd);
      }
</code></pre>

<p>It returns void on line 3 saying unexpected char '\' even though there is no \</p>
]]></description>
   </item>
   <item>
      <title>[INSTALL_FAILED_INSUFFICIENT_STORAGE]</title>
      <link>https://forum.processing.org/two/discussion/8715/install-failed-insufficient-storage</link>
      <pubDate>Thu, 18 Dec 2014 03:00:00 +0000</pubDate>
      <dc:creator>philspitler</dc:creator>
      <guid isPermaLink="false">8715@/two/discussions</guid>
      <description><![CDATA[<p>Hi, when I try and run a sketch on myAndroid device i get the following error.</p>

<p>[INSTALL_FAILED_INSUFFICIENT_STORAGE]</p>

<p>There is plenty of room on the device and the sketch is tiny.</p>

<p>Any ideas or tests I can do?</p>

<p>Thanks.</p>

<p>Phil</p>
]]></description>
   </item>
   <item>
      <title>cannot export a working application</title>
      <link>https://forum.processing.org/two/discussion/7834/cannot-export-a-working-application</link>
      <pubDate>Mon, 27 Oct 2014 15:11:49 +0000</pubDate>
      <dc:creator>devilesence</dc:creator>
      <guid isPermaLink="false">7834@/two/discussions</guid>
      <description><![CDATA[<p>i have tried alot with exporting my code , with tools , putting font file in the folder but nothing works. the application works fine when ran from the IDE. but when exported, gives an infinte blank screen. the main things that may cause problems are the font i used(have already put in folder) , the g4p library (already in the lib folder), code with UART i heard had some problem exporting with 2.2.1v . i had ran 2.1.1 but it also labels 2.2.1 . so far no luck . the code is to long isnt posting here</p>
]]></description>
   </item>
   <item>
      <title>Sublime / Processing Parsing Error</title>
      <link>https://forum.processing.org/two/discussion/7239/sublime-processing-parsing-error</link>
      <pubDate>Fri, 19 Sep 2014 12:40:52 +0000</pubDate>
      <dc:creator>CodedLife</dc:creator>
      <guid isPermaLink="false">7239@/two/discussions</guid>
      <description><![CDATA[<p>Today I woke up, opened Sublime with my Processing code in it, ran it, and got a pop-up window with this written in it:</p>

<p>Error trying to parse build system: No data in ~/Library/Application Support/Sublime Text 2/Packages/Processing/Processing.sublime-build:1:1</p>

<p>As a result, I cannot run my code...</p>

<p>What is the issue ? 
Did this every happen to you or someone you know ? 
Does it have to do with my version of Processing ?</p>

<p>Thank you !!!</p>
]]></description>
   </item>
   <item>
      <title>Logging Arduino data as .csv</title>
      <link>https://forum.processing.org/two/discussion/7107/logging-arduino-data-as-csv</link>
      <pubDate>Tue, 09 Sep 2014 16:36:24 +0000</pubDate>
      <dc:creator>NewStart</dc:creator>
      <guid isPermaLink="false">7107@/two/discussions</guid>
      <description><![CDATA[<p>Hello everybody, I need your help please.</p>

<p>I am trying to log accelerometer data (via Processing 2.2.1) as .csv file to allow me to graphically present the data in Excel, however I am struggling with the Processing code. When I run the following it presents the error:  "The function readArduinoInt() does not exist". I have extensively searched this issue for the past 3 nights and drawn a blank. I have taken this sketch directly from O'Reilly's Arduino Cookbook. Any pointers would be greatly appreciated.</p>

<pre><code>/*
* ReceiceMultipleFieldsBinarytoFile_P
* portIndex must be set to the port connected to the Arduino
* based on ReceiceMultipleFieldsBinarytoFile, tis version saves data to file
* Press any key to stop logging and save file
*/

import processing.serial.*;
import java.util.*;
import java.text.*;

PrintWriter output;
DateFormat fnameFormat= new SimpleDateFormat("yyMMdd_HHmm");
DateFormat timeFormat = new SimpleDateFormat("hh:mm:ss");
String fileName;

Serial myPort;    // Create object from Serial Class
short portIndex = 4;  // Select the com port, 0is the first port
char HEADER = 'H';

void setup()
{
  size(200, 200);
  //Open whatever serial port is connected to Arduino.
  String portName = Serial.list()[portIndex];
  println(Serial.list());
  println(" Connecting to -&gt; " + Serial.list()[portIndex]);
  myPort = new Serial(this, portName, 9600);
  Date now = new Date();
  fileName = fnameFormat.format(now);
  output = createWriter(fileName + ".csv"); // save the file in the sketch folder
}

void draw()
{
  int val;
  String time;

  if ( myPort.available() &gt;= 15)    // wait for the entire message to arrive
  {
    if ( myPort.read() == HEADER)    // is this the Header
    {
      String timeString = timeFormat.format(new Date());
      output.print(timeString);
      val = readArduinoInt(); 
      // read but don't output the digital values

      // output the six analogues values delimited by a coma
      for(int i=0; i &lt; 6; i ++){
        val = readArduinoInt();
        output.print("," + val);
      }
      output.println();
    }
  }
}

void keyPressed() {
  output.flush();  // Writes the remaining data to the file
  output.close();  // Finishes the file
  exit();  // Stops the program
}

// return the integer value from bytes received on the serial port
// (in low,high order)
int readAduinoInt()
{
  int val;    // Data received from the serial port

  val = myPort.read();    // read the least significant byte
  val = myPort.read() * 256 + val;  // add the most signifcant byte
  return val;
}
</code></pre>

<p>Many thanks NS</p>
]]></description>
   </item>
   <item>
      <title>Always get: "Client got end-of-stream" ERROR</title>
      <link>https://forum.processing.org/two/discussion/7106/always-get-client-got-end-of-stream-error</link>
      <pubDate>Tue, 09 Sep 2014 15:50:22 +0000</pubDate>
      <dc:creator>Fab_03</dc:creator>
      <guid isPermaLink="false">7106@/two/discussions</guid>
      <description><![CDATA[<p>Hi people!
I'm just getting crazy trying to solve this issue, nobody else seems to encounter the same problem.
I'm writing a simple android application (<em>Client</em>) which sends a string using a 'Socket' once a button is pressed. Then Processing on my laptop (<em>Server</em>) is going to receive and handle it.
The problem occurs in Processing when the android app closes the socket with 'socket.close()'. Processing returns the following exception: <strong>SocketException Client got end-of-stream.</strong>
<em>If I don't close the socket everithing works fine and no errors seem to appear, but when I close the java window processing gives as many exception as the sockets opened during the java applet life and closes them all: I think that this is not good. Then everyone say that sockets should be closed.</em></p>

<p>Here is the app code (<em>Client</em>):</p>

<pre><code>public void onClick(View view) {
            t = T.getText().toString();
            if (view.getId() == R.id.send_button) { //check button through its id and set string to send.
                msg = t+" "+string1;
            }
            serverIpAddress = serverIp.getText().toString();
            serverInPort = Integer.parseInt(serverPort.getText().toString());
            if (!serverIpAddress.equals("") &amp;&amp; serverInPort != 0) {
                sendMsg(msg);
            }
        }

public void sendMsg(String msg) { // Function to send TCP string
        try {
            InetAddress serverAddr = InetAddress.getByName(serverIpAddress);
            Log.d("MainActivity", "C: Connecting...");
            Socket socket = new Socket(serverAddr, serverInPort);
            try {
                Log.d("MainActivity", "C: Sending...");
                PrintWriter out = new PrintWriter(new BufferedWriter(
                        new OutputStreamWriter(socket.getOutputStream())), true);
                out.println(msg);
                Log.d("MainActivity", "C: Sent.");
                Toast.makeText(this, msg, duration).show();
            } catch (Exception e) {
                Log.e("MainActivity", "S: Error.", e);
            }
            socket.close();
            Log.d("MainActivity", "C: Closed.");
        } catch (Exception e) {
            Log.e("MainActivity", "C: Error.", e);
        }
    }
</code></pre>

<p>And this is the Processing testing code (<em>Server</em>):</p>

<pre><code>int port = 1111;       
Server server;

void setup()
{
  size(400, 400);
  background(0);
  server = new Server(this, port);
}

void draw()
{
  // Get the next available client
  Client thisClient = server.available();
  // If the client is not null, and says something, display what it said
  if (thisClient !=null) {
    String incomingMsg = thisClient.readString();
    if (incomingMsg != null) {
      print(thisClient.ip() + "," + port + ": " + incomingMsg);
    } 
  } 
}
</code></pre>

<p>Any help would be appreciate.
Many thanks in advance</p>

<p>Fab</p>
]]></description>
   </item>
   <item>
      <title>Struggles exporting sketch</title>
      <link>https://forum.processing.org/two/discussion/7025/struggles-exporting-sketch</link>
      <pubDate>Thu, 04 Sep 2014 09:15:48 +0000</pubDate>
      <dc:creator>morty</dc:creator>
      <guid isPermaLink="false">7025@/two/discussions</guid>
      <description><![CDATA[<p>Hi! I am in desperate need of help.</p>

<p>I just downloaded processing and took a deep dive trying to learn it on my own and create a project for school. I am VERY new to the program and coding in general.</p>

<p>.......</p>

<p>Just to get a feel for the program I took some sample code and made a little prototype. The app runs smooth as butta, but upon attempting to export I get a whole slew of error messages I am unable to decode.</p>

<p><strong>Here is my code:</strong></p>

<pre><code>// setup - runs one time
void setup()
  {
  // set a stage size of 500 x 500 pixels
  size (500,500);

  // smooth all drawing
  smooth();

  // don't draw an outline around your shapes
  noStroke();

  }

  void draw() {
  // Call the variableEllipse() method and send it the
  // parameters for the current mouse position
  // and the previous mouse position
  variableEllipse(mouseX, mouseY, pmouseX, pmouseY);
}
void variableEllipse(int x, int y, int px, int py) {
  float speed = abs(x-px) + abs(y-py);
  stroke(speed);
  ellipse(x, y, speed, speed);
}

// mousePressed - runs every time the mouse is pressed
void mousePressed()
  {
  fill (random(0,255), random(0,255), random(0,255), 50);
  }
</code></pre>

<p><strong>And here are the error messages</strong></p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/961/N5PNAPAT7CWC.PNG" alt="errormessages" title="errormessages" /></p>

<p>Thank you SOOO much I feel so frustrated I could cry and this is due next Thursday. I would be eternally grateful for any assistance.</p>
]]></description>
   </item>
   <item>
      <title>PVector.random2D() is javascript mode gives error "Uncaught TypeError: undefined is not a function"</title>
      <link>https://forum.processing.org/two/discussion/6844/pvector-random2d-is-javascript-mode-gives-error-uncaught-typeerror-undefined-is-not-a-function</link>
      <pubDate>Wed, 20 Aug 2014 19:34:41 +0000</pubDate>
      <dc:creator>rebirth</dc:creator>
      <guid isPermaLink="false">6844@/two/discussions</guid>
      <description><![CDATA[<p>Execute this in 2.2.1 and get the above error.</p>

<p><code>
void setup()
{
  PVector v = PVector.random2D(); 
}
</code></p>

<p>Should I file a bug report?</p>
]]></description>
   </item>
   <item>
      <title>Android Build Problems</title>
      <link>https://forum.processing.org/two/discussion/5493/android-build-problems</link>
      <pubDate>Sat, 31 May 2014 11:58:18 +0000</pubDate>
      <dc:creator>Flu</dc:creator>
      <guid isPermaLink="false">5493@/two/discussions</guid>
      <description><![CDATA[<p>I have something like a pretty big problem...I made a very simple test program that draws a line in Android mode. When I try to Run in Emulator, it says "Error running javac.exe compiler" and it writes me there that the error was made when executing the next line... and writes the path of a file called build.xml. I went into the Android SDK Manager and downloaded and installed everything I could, but it still comes with the same error and there's nothing I can do. Somebody help me please?</p>
]]></description>
   </item>
   <item>
      <title>"cannot convert from void to boolean" mystery ...</title>
      <link>https://forum.processing.org/two/discussion/6429/cannot-convert-from-void-to-boolean-mystery</link>
      <pubDate>Sun, 20 Jul 2014 20:42:02 +0000</pubDate>
      <dc:creator>ALMoD</dc:creator>
      <guid isPermaLink="false">6429@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone!</p>

<p>My problem is a mystery to solve!
 I was trying learning Casey Reas Compendium here <a rel="nofollow" href="http://www.peepproject.com/tutorials/tutorial/25/view">peepproject.com/tutorials/tutorial/25/view</a>, which have is own running interface as you see... Everything is working in this interface, but not in MY processing programme... I have updated yesterday to the last version, maybe is the reason why, but this part of code doesn't want to work :</p>

<pre><code>for(int i=0; i&lt;circles.length;i++){
      Circle other=circles[i];
        if(touching(other)){    //here is the error message
        line(x,y,other.x,other.y);
      }
    }
</code></pre>

<p>And this beautiful message appears... but not in the running window on the website... SO... If anyone can explain me why it would be really cool! :)
Is it a modification due to update version?</p>

<p>Thanks a lot! 
Have a beautiful night!</p>
]]></description>
   </item>
   <item>
      <title>Error on Start Emulator on Processing Android</title>
      <link>https://forum.processing.org/two/discussion/5970/error-on-start-emulator-on-processing-android</link>
      <pubDate>Mon, 23 Jun 2014 12:08:35 +0000</pubDate>
      <dc:creator>paulo101977</dc:creator>
      <guid isPermaLink="false">5970@/two/discussions</guid>
      <description><![CDATA[<p>Error :</p>

<p>BUILD FAILED
/tmp/android1759985374400238697sketch/build.xml:13: Cannot find /home/paulo/Ãrea de Trabalho/adt-sdk/sdk/tools/ant/build.xml imported from /tmp/android1759985374400238697sketch/build.xml</p>

<p>Total time: 0 seconds</p>

<p>I using Linux Ubuntu 64 bits .</p>
]]></description>
   </item>
   <item>
      <title>Interrupt code not working</title>
      <link>https://forum.processing.org/two/discussion/5854/interrupt-code-not-working</link>
      <pubDate>Tue, 17 Jun 2014 13:21:09 +0000</pubDate>
      <dc:creator>columbus1231</dc:creator>
      <guid isPermaLink="false">5854@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I got this stepper motor running code and it works fine. However I am trying to write a code to enable me to pause it and turn on led on pin 13, when I press a button and then have it continue running where it left off when I release the button.
I tried by attaching an interrupt but it didn’t work. The modifications I made are in bold. Anyone know what I did wrong?
I’m using an Arduino mega 2560.
Here is the code below. Any help will be appreciated.</p>

<pre><code>//////////////////////////////////////////////////////////////////
//©2011 bildr
//Released under the MIT License - Please reuse change and share
//Using the easy stepper with your arduino
//use rotate and/or rotateDeg to controll stepper motor
//speed is any number from .01 -&gt; 1 with 1 being fastest - 
//Slower Speed == Stronger movement
/////////////////////////////////////////////////////////////////
#include &lt;avr/interrupt.h&gt;

# define LED_PIN 13
# define SWITCH_PIN 5      // pin 18 for interrupt on Arduino mega 2560

#define DIR_PIN 2
#define STEP_PIN 3

void setup() { 
  pinMode(DIR_PIN, OUTPUT); 
  pinMode(STEP_PIN, OUTPUT); 
  pinMode(LED_PIN, OUTPUT);
  // switch input
  pinMode(18, INPUT);
  // attach the interrupt on pin 18
  attachInterrupt(SWITCH_PIN, light, LOW);
} 

void light() {
  digitalWrite(LED_PIN, HIGH);
}

void loop(){ 

  //rotate a specific number of degrees 
  rotateDeg(360, 1); 
  delay(1000);

  rotateDeg(-360, .1);  //reverse
  delay(1000); 


  //rotate a specific number of microsteps (8 microsteps per step)
  //a 200 step stepper would take 1600 micro steps for one full revolution
  rotate(1600, .5); 
  delay(1000); 

  rotate(-1600, .25); //reverse
  delay(1000); 
}



void rotate(int steps, float speed){ 
  //rotate a specific number of microsteps (8 microsteps per step) - (negitive for reverse movement)
  //speed is any number from .01 -&gt; 1 with 1 being fastest - Slower is stronger
  int dir = (steps &gt; 0)? HIGH:LOW;
  steps = abs(steps);

  digitalWrite(DIR_PIN,dir); 

  float usDelay = (1/speed) * 70;

  for(int i=0; i &lt; steps; i++){ 
    digitalWrite(STEP_PIN, HIGH); 
    delayMicroseconds(usDelay); 

    digitalWrite(STEP_PIN, LOW); 
    delayMicroseconds(usDelay); 
  } 
} 

void rotateDeg(float deg, float speed){ 
  //rotate a specific number of degrees (negitive for reverse movement)
  //speed is any number from .01 -&gt; 1 with 1 being fastest - Slower is stronger
  int dir = (deg &gt; 0)? HIGH:LOW;
  digitalWrite(DIR_PIN,dir); 

  int steps = abs(deg)*(1/0.225);
  float usDelay = (1/speed) * 70;

  for(int i=0; i &lt; steps; i++){ 
    digitalWrite(STEP_PIN, HIGH); 
    delayMicroseconds(usDelay); 

    digitalWrite(STEP_PIN, LOW); 
    delayMicroseconds(usDelay); 
  } 
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>error while compiling (cannot convert from float to int)</title>
      <link>https://forum.processing.org/two/discussion/5656/error-while-compiling-cannot-convert-from-float-to-int</link>
      <pubDate>Sat, 07 Jun 2014 18:18:53 +0000</pubDate>
      <dc:creator>lolnyancats</dc:creator>
      <guid isPermaLink="false">5656@/two/discussions</guid>
      <description><![CDATA[<pre><code>Person player;
int dist=100;
int[] speeds = {
  5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100
};
float objectTypes=random(1, 5);
int gravity=20;
int[] rectX = {
  500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500
};
int speed=5;
int currentSpeed = speeds[min(frameRate, speeds.length)];

void setup() {
  size(500, 500);
  player = new Person(color(0, 0, 0), 100, 400, speed[0]);
}

void draw() {
  frameRate(60);
  background(105);
  player.run();
  player.display();
}

class Person {
  color c;
  float xpos;
  float ypos;
  float xspeed;

  Person(color tempC, float tempXpos, float tempYpos, float tempXspeed) {
    c=tempC;
    xpos=tempXpos;
    ypos=tempYpos;
    xspeed=tempXspeed;
  }

  void display() {
    noStroke();
    fill(c);
    rectMode(CENTER);
    rect(100, 400, 10, 10);
    if (objectTypes==1) {
      rect(currentSpeed, 400, 20, 20);
    }
    if (objectTypes==2) {
    }
    if (objectTypes==3) {
    }
    if (objectTypes==4) {
    }
    if (objectTypes==5) {
    }
  }

  void run() {
    if ( speed &lt; 100) {
      speed+=5;
    }
  }
}
</code></pre>

<p>it says cannot convert from float to int as the error.</p>
]]></description>
   </item>
   <item>
      <title>Loading Images</title>
      <link>https://forum.processing.org/two/discussion/5507/loading-images</link>
      <pubDate>Sun, 01 Jun 2014 10:33:30 +0000</pubDate>
      <dc:creator>informer91</dc:creator>
      <guid isPermaLink="false">5507@/two/discussions</guid>
      <description><![CDATA[<p>Ok so I am developing a sketch that requires loading in alot of images.</p>

<p>I have two type Gifs and pngs. I am getting a slow sketch at startup and sometimes an out of memory error. I know this is due to loading alot of images at start-up.</p>

<p>I just want to know if there is a java or processing method for loading and trashing images dynamically or loading  them outside of setup() only when needed to be drawn??</p>

<p>Cheers in advance</p>
]]></description>
   </item>
   <item>
      <title>HUGE image array</title>
      <link>https://forum.processing.org/two/discussion/5512/huge-image-array</link>
      <pubDate>Sun, 01 Jun 2014 14:52:26 +0000</pubDate>
      <dc:creator>informer91</dc:creator>
      <guid isPermaLink="false">5512@/two/discussions</guid>
      <description><![CDATA[<p>Ok i need to use 1000 + images in my sketch. I have a few questions about how best to do this to avoid memory error.</p>

<p>1) can I load an image(s) from a file when I need to draw it instead of loading at runtime in setup?
2) if not, does loading image file on a new thread actually benefit the sketch as either way 1000 images will be loaded?
3) Is there a method to dynamically load and remove images from RAM as I need/no longer need them??</p>
]]></description>
   </item>
   <item>
      <title>Help needed with Sound</title>
      <link>https://forum.processing.org/two/discussion/5220/help-needed-with-sound</link>
      <pubDate>Sat, 17 May 2014 13:32:48 +0000</pubDate>
      <dc:creator>hendrixnash</dc:creator>
      <guid isPermaLink="false">5220@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I'm currently having some issues with having sound on my piece.</p>

<p>I want it so that whenever I press inside a hotspot, sound plays, and then when the mouse is released from the hotspot, the sound stops.</p>

<p>The issue, however, is that if the very first click is outside of the hotspot, Processing attempts to stop sound that has not yet been loaded and hasn't played yet. If the very first click is inside the hotspot, the sound loads and plays and can stop as I want it to do.</p>

<p>The code is as follows :</p>

<pre><code>/****************************************************
  * WHITENOISE
  * by Hendrix Nash
  * 07.05.14
  *
  * 
  * 
  ***************************************************/
                                                                                        //
import ddf.minim.*;

AudioPlayer player ;
Minim noise; 

boolean isMouseDown ; 

int rectangleLocationX , rectangleLocationY ;
int rectangleWidth , rectangleHeight ;
int whiteRectWidth , whiteRectHeight ;
int whiteRectsDist ;
int blankRectLocationX , blankRectLocationY ;
int blankRectWidth , blankRectHeight ;
int textLocationX , textLocationY ;
int intersectLeft , intersectRight , intersectTop , intersectBottom ;
String credit = "H E N D R I X N A S H // W H I T E N O I S E" ;

void setup() {
  size ( 500 , 500 ) ;
  frameRate ( 8 ) ;
  background ( 255 ) ;
  colorMode ( RGB , 255 , 255 , 255 , 100 ) ; 
  rectMode ( CENTER ) ; 
  loadFont ("Raleway-Medium-14.vlw") ;

  rectangleLocationX = width/2 ;
  rectangleLocationY = rectangleLocationX ;
  rectangleWidth = 400 ;
  rectangleHeight = rectangleWidth ;
  whiteRectWidth = rectangleWidth/2 ; 
  whiteRectHeight = whiteRectWidth ; 
  whiteRectsDist = 10 ;
  blankRectLocationX = width/2 ;
  blankRectLocationY = 475 ;
  blankRectWidth = width ;
  blankRectHeight = 50 ;
  textLocationX = width/2 ;
  textLocationY = 475 ;
  intersectLeft = ( width/2 ) - whiteRectWidth/2 ;
  intersectRight = ( width/2 ) + whiteRectWidth/2 ;
  intersectTop = ( height/2 ) - whiteRectHeight/2 ;
  intersectBottom = ( height/2 ) + whiteRectHeight/2 ;
}


void draw() {
  fill ( random(255) , random(255) , random(255) , random(75) ) ;
  rect ( rectangleLocationX , rectangleLocationY , rectangleWidth , rectangleHeight ) ;

  if ( isMouseDown == false ) {
    noFill() ;
    stroke ( 255 ) ;
    rect ( width/2, height/2, whiteRectWidth , whiteRectHeight ) ;
  }  
  else {
    int counter = 0 ; 
    int loops = 20 ;

    while ( counter &lt; loops ) {    
      int rectangleLocationY = 155 + counter * whiteRectsDist ; 
      int shakeAmount = 10 ;
      int addX = ( int ) random ( -shakeAmount , shakeAmount ) ;
      int addY = ( int ) random ( -shakeAmount , shakeAmount ) ;

      rect ( rectangleLocationX + addX , rectangleLocationY + addY , 200 , 5 ) ;
      counter++ ; 
    }
  }

  fill ( 255 ) ;
  rect ( blankRectLocationX , blankRectLocationY , blankRectWidth , blankRectHeight ) ;

  fill ( 200 ) ;
  textSize ( 14 ) ;
  textAlign ( CENTER ) ;
  text ( credit , textLocationX , textLocationY ) ;  


}

void mousePressed() {
  isMouseDown = detectIntersection() ;     
  if (isMouseDown == true) {
   noise = new Minim ( this ) ;
   player = noise.loadFile ( "whiteNoise.wav" , 1500 ) ;
   player.play() ;
  }

}

void mouseReleased() {
  isMouseDown = false ; 
  noise.stop();

}

boolean detectIntersection() {
  boolean isInside = false ;

  if ( mouseX &gt; intersectLeft &amp;&amp; mouseX &lt; intersectRight ) {
      if ( mouseY &gt; intersectTop &amp;&amp; mouseY &lt; intersectBottom ) {
        isInside = true ;
      }
  }
  return isInside;
}
</code></pre>

<p>If anybody is able to help, I'd appreciate it so much. Thanks in advance</p>
]]></description>
   </item>
   <item>
      <title>Updating to Processing 2.1.2</title>
      <link>https://forum.processing.org/two/discussion/4656/updating-to-processing-2-1-2</link>
      <pubDate>Thu, 24 Apr 2014 06:41:58 +0000</pubDate>
      <dc:creator>harpopan</dc:creator>
      <guid isPermaLink="false">4656@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>I've updated the Processing app to 2.1.2 version, and now, I have a lot of sketches that doesn't work. Most of them say me that they can't load/found the images. I reviewed the changes/log file and I didn't found anything about that. Any idea?</p>
]]></description>
   </item>
   </channel>
</rss>