Loading...
Logo
Processing Forum
I want to see the values from the analog pin on the Arduino Uno printed out in Processing. It works fine in Arduino, but I can't even get a zero to pop up from processing (which seems to be the usual complaint), just an empty gray box.

Here is my Arduino Code:

Copy code
  1. #include <Boards.h>
    #include <Firmata.h>



    const int voltPin = 0;
    float denominator;
    int resistor1 = 51000;        //resistors from amp
    int resistor2 = 4300;       
    int inputPin = A0;

    void setup() {
      Serial.begin(9600);
      denominator = (float)resistor2 / (resistor1+resistor2);
    }
    void loop() {
      float analogvoltage;
      float voltagereading;
      float finalvoltage;
      analogvoltage= analogRead(A0);
      voltagereading=(analogvoltage/1024)*5;      //percent of total bits used times voltage range
      finalvoltage=analogvoltage/denominator;   //voltage adjusted for amp
      Serial.println(finalvoltage, 10);        //returns value, to ten decimal places
      delay(10);
Then in Processing
Copy code
  1. import processing.serial.*;
    import cc.arduino.*;

    Arduino arduino;
    int analogPin = 0;
    int value = 0;

    void setup(){
     arduino = new Arduino(this, Arduino.list()[0], 57600);
    }

    void draw(){
    value = arduino.analogRead(analogPin);
    println(value);
    delay(10);
    }


Thanks in advance for looking through this!