Search code examples
arduinoprocessingfirmata

Processing: can't get analog value


Working on a project and need to trigger something when my pressure sensor got pressed. I want to use processing for triggering some audio samples and there is where my problem is: Processing always log 0 when the sensor is pressed.

First I made a sketch in arduino for testing my setup and sensor: everything works well, the pressure sensor logging correctly.

Now I uploaded the firmata default sketch, made a sketch in processing, no errors but the pressure sensors don't log correctly, it stays 0.

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


int aPin = 0;
int bPin = 1;
int cPin = 2;

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

void draw()
{
int aValue = arduino.analogRead(aPin);
int bValue = arduino.analogRead(bPin);
int cValue = arduino.analogRead(cPin);
println (aValue);
println (bValue);
println (cValue);
delay(1000);
}

What am I doing wrong?


Solution

  • Arduino.list()[0] was not correct.