Step 3: Test the code and calibrate sensor range

1.Use the following code in processing:

import processing.serial.*;
import cc.arduino.*;

Arduino arduino; //creates arduino object

color back = color(64, 218, 255); //variables for the 2 colors

int sensor= 0;
int read;

float value;

void setup() {
  size(800, 600);
  arduino = new Arduino(this, Arduino.list()[0], 57600); //sets up arduino
    arduino.pinMode(sensor, Arduino.INPUT);//setup pins to be input (A0 =0?)

void draw() {
  println (read);
  value=map(read, 0, 680, 0, width); //use to callibrate  
  ellipse(value, 300,30, 30);


2. Use the “println” command to output your sensor’s minimum and maximum values. They will be different depending on the context. Plug the min and max values in your map() function.
<p>I am receiving 0 values all across the board when I put the first sample code in.</p>
<p>Hi Zac,</p><p>I think it depends on which accelerometer you are using. The connections might be different. If you are not getting any values it might be that the accelerometer is connected wrong (see image for a different accelerometer).</p><p>I made a more detailed manual here: <a href="http://snebtor.org/sensing4viz/sensing_for_visualization_big.pdf" rel="nofollow">http://snebtor.org/sensing4viz/sensing_for_visuali...</a></p>
<p>Here is the link to some information i've found.</p><p>I've had the same issue using analogRead(A0);<br>You can translate the a0 pin to a 14, a1 to 15 and so on until a7 wich is 21.</p><p><br>http://electronics.stackexchange.com/questions/67087/analogread0-or-analogreada0</p>
<p>Good catch! -Thank you. I got confused when they added the A1 thing</p>

About This Instructable