Issue communicating with Arduino

I have a phototransistor and an LED, when I test in Arduino I do get readings from the phototransistor, but when trying to get the same readings in Processing I just get continuous 0’s. Can any one help? I’ve placed the code below. The phototransistor is connected to port A1. Thanks!

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

int PhotoPin1 = 1;
Arduino port;
float W= 0;
void setup(){
port= new Arduino(this, Arduino.list()[17], 9600);
port.pinMode(PhotoPin1, Arduino.INPUT);
}

void draw() {

float w_sensorRaw1= port.analogRead(PhotoPin1);
println(w_sensorRaw1);
println(W);
delay(1000);
}
1 Like

Hi, try to assign float var in that way:

float W = 0.0;

This syntax force the compiler to use a float value…

1 Like

Please don’t create duplicate posts.

Continue discussion here: https://discourse.processing.org/t/issue-with-reading-arduino-port/7846

Kf

1 Like