Pages: [1]   Go Down
Author Topic: Problem Serial.available() = 0, ( SOLVED )  (Read 364 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi, i always control arduino via serial  without problem. but I changed my pc, and i cant send data from pc to arduino, and now when I do it I always obtain "Serial.available() = 0"
even with the most basic program to do it i obtain "Serial.available() = 0"

Code:
void setup() {
    Serial.begin(9600);
}
void loop() {      
if (Serial.available() > 0) {
}
        else{
            Serial.println("serial is not available");
}}

i always obtain "serial is not available" in my new pc, i return to the old pc and  works perfect

can any help me? thanks!
« Last Edit: May 14, 2013, 11:53:31 am by ignaciot » Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 65
Posts: 2107
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to send data to it for any other result. Serial.available() only returns the number of bytes in the receive buffer, not weather the serial functionality is available.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i always send data from monitor serial or matlab to arduino, but now these data are not read. obviously i erase this line
Code:
Serial.println("serial is not available");
in my programs
« Last Edit: May 14, 2013, 12:51:35 am by ignaciot » Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What baud rate is the Serial monitor set to ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

9600 also
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i think that my PC have a driver problem, but i can send data via serial using serial.print from arduino to PC.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I solved it! at left  "blaud rate" in monitor serial I select "carriage return". thanks!
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That does not make any sense. 
What you have done is to tell the Serial monitor to append a Carriage Return to the text sent to the Arduino, but the code that you posted does not rely on the CR being present.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Pages: [1]   Go Up
Jump to: