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!
@Ryan12,
possibly this is first time you use serial interface in processing,
and you started with a
arduino ( firmata )
example.
this ONLY can work if the arduino is loaded with the firmata sketch.
when you say that you see the data incoming
in the arduino IDE monitor ( terminal emulator )
you not have firmata loaded to arduino,
you have your own code sending data continuously by serial.println()
in that case you only use in processing the
import processing.serial.*;
and how to setup see for a example for that library (only )
//__________________________________
also can you tell us where the
come from?
it is good practice to first print the port list.
I had uploaded the firmata sketch to the Arduino, but I still was having the issue. The 17 comes from the list, I just had it commented out after I had it set. Also regarding using just serial, can I do that if I’m using one of the pins as an input, because I need to read it and then output what the pin’s value is?
it looks to me that despite having the correct port connected there is 0 connection to the Arduino. Code that has worked in the past is no longer working
the reason why i made this version of code was to
allow that loop back by making a jumper cable
A0 ↔ D5
so when you click on the [ D5 ] button the D5 output should change
( what you also can verify with a voltmeter )
and via that jumper cable the A0 input jump from
0 to 5V ( what you should see in the A0 bar graph and the volt number…
//__________________
if you think that your code has worked
but now still runs, but show allways 0
there might be a hardware / or port problem
of the arduino board. But i only see burned out Douts
( from a short circuit ) or arduinos what stopped working completely.
anyhow go back to
Arduino IDE, load a blinky and a analog read example and test with the
build in monitor.
Right so when I test analogRead in Arduino and just jump between 3.3V, 5V, and Ground the serial monitor shows it properly reading these values. I also got a Hello World to work with serial, and a primitive Serial read to show changing values code below:
in the first code you load the firmata lib to processing sketch but not use it,
( and all lines what contain the word "arduino " should be removed )
using the serial lib only works for you / as you test it against your own arduino code?? /
in the second code you use the firmata lib,
but not say that you uploaded firmata to arduino, so it can not work!
also when you tested my processing firmata example,
did you upload the standard firmata to arduino first?
like i show detailed in that many pictures blog extra for you?
and when you test your second processing code
( what also is a firmata code )
you changed arduino also from your sketch to firmata?
when your processing gives you a 0.0, did you measure voltage at that arduino pin?
//____________
anyhow i try to play with your "second code "
and yes, i got 0 too!!
now that was bad, as i just
loaded firmata
test my sketch and connect A0 to 5V and all ok
test your sketch and it did not work…
so i play until i see something,
it was the baud rate ! 57600 !
see all arduino ( firmata ) examples have that rate and http://playground.arduino.cc/Interfacing/Processing
here too, even suggest you can omit that parameter?