Arduino not able to send serial data back?

When dealing with serial connections make sure of the following key points.

When dealing with serial connections make sure of the following key points: BAUD Rates match DATABITS should match STOPBITS should match PARITY should match Make sure you are using the correct cable (Null modem if needed) Make sure the cable run isn't too long All of the above can cause odd stuff to come out of the com port on the Java side. Once you get the hang of this it gets much easier. My personal favorite library here.

It's most probably a virtual COM port and the cable is a USB cable, unless the arduino board is pretty old. If it were a real RS232C connection one could also consider the type of handshaking :) – Maciej Hehl Apr 30 '10 at 14:56 It is the duemilanove Im using, I am already using the RXTX library imported into the Netbeans IDE I use. I am able to send data to the serial monitor in netbeans, and receive the data sent from the arduino, but I cant receive the data and interfer with the ardiuno, such as using an If statement, maybe my data is sent wrong?

– Casper Marcussen Apr 30 '10 at 17:55 @Maciej H I have used the arduino with java and with other components I just know with that I have had to adjust these parameters to get everything to play nice. – Jeff Beck Apr 30 '10 at 18:31 1 @Casper can you post the code you are using and a link to the board you are using? – Jeff Beck Apr 30 '10 at 18:31.

Package serialtalk; import gnu.io. CommPortIdentifier; import gnu.io. SerialPort; import java.io.

InputStream; import java.io. OutputStream; import processing.app. Preferences; public class Main { static InputStream input; static OutputStream output; public static void main(String args) throws Exception{ Preferences.init(); System.out.

Println("Using port: " + Preferences. Get("serial. Port")); CommPortIdentifier portId = CommPortIdentifier.

GetPortIdentifier( Preferences. Get("serial. Port")); SerialPort port = (SerialPort)portId.

Open("serial talk", 4000); input = port.getInputStream(); output = port.getOutputStream(); port. SetSerialPortParams(Preferences. GetInteger("serial.

Debug_rate"), SerialPort. DATABITS_8, SerialPort. STOPBITS_1, SerialPort.

PARITY_NONE); while(true){ while(input.available()>0) { System.out. Print((char)(input.read())); } } } } This is the code im using, provided by this person: http://silveiraneto.net/2009/03/01/arduino-and-java/ The Arduino is this: http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove The code simpley receives a number, and determines which analog reading it should be sending back, from my arduino I am not very experienced with these libraries, but I know the basic about java. Sorry couldn't comment such a big post.

Please post Your code for the Arduino too. Especially the setup() function – Maciej Hehl Apr 30 '10 at 21:04 It's very simple, since I was thinking that I could handle the serial reading in the Loop function: Void setup() { Serial. Begin(9600); void loop() { if (Serial.available() > 0) { Serial.

Println("I've got a signal"); } Serial. Println("I didn't receive any data"); delay(1000); } I have also tried with just printing numbers such as 33 and 42, but it does not change anything. The porpuse is getting the Arduino connected to a java program, and making the java generate a number from math.

Random, and set one of the LEDs as high, and read the analog value, and decide if it is high enough. – Casper Marcussen Apr 30 '10 at 23:32 Is this possible to do by exchanging the sort of commands through serial connection? – Casper Marcussen Apr 30 '10 at 23:33 Hm I'm not sure what this line does, but I have a gut feeling, that it sets the baudrate.Port.

SetSerialPortParams(Preferences. GetInteger("serial. Debug_rate").

If the debug rate is the same as the one used for uploading programs to the board It might be different than 9600. I think the bootloader operates at 19200. Check it out – Maciej Hehl May 1 '10 at 1:10 1 One more thing.

You have to wait a bit after opening the port before sending anything to the board. After opening the port arduino is automatically reset and bootloader starts. You have to wait until it timeouts and the execution goes to Your code – Maciej Hehl May 1 '10 at 1:14.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions