Hi! I'm really new in arduino and this this is a new arduino uno that I bought 3 days ago. Really hope there is nothig wrong with the hardware.
I couldn't do Serial.read(), and so I set this code to check if there is available space in the memory.
This is the code, really simple one...
I set this code to check if there is available space in the memory.
There is nothing in that sketch that would show you available SRAM. All you are doing is printing 'error' all the while there is nothing in the Serial input buffer.
and so I set this code to check if there is available space in the memory
No that code checkes if there is any serial data in the buffer.
It will keep saying error forever. Because it only gets done once in setup it will never say anything else as a reset clears any previously received data.
Craiglin19:
And it just keep saying "error" in serial monitor.. I dont know why...
Well, given that the program you wrote outputs the string "error" to the serial port, and that output would show up in the serial monitor, what exactly is unexpected about what you are seeing?
If you change the string "error" to "everything A-OK!" perhaps that will be more encouraging?
Edit: Reading between the lines, I'm guessing you think the Serial.available() method reports on SRAM availability?
Serial.available() does something completely different: It tells you how many input character are in the serial input buffer waiting to be read by Serial.read(). So Serial.available()==0 will almost certainly always be true given you've placed this test in the setup section of your program.
Have a careful read of the references pages to the various functions and classes, and perhaps study some of the example sketch programs to see how things can fit together. Good luck!
Thanks everyone!! That really helps a lot.But my problem is still there..
dxw00d: @Craiglin19 - Perhaps, if you posted the original sketch that was causing you problems, we could help you figure out why.
Em this is the original sketch:
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
This is an example on arduino site, and when it's running, there's nothing happen on my serial monitor.. And this is the reason why I set that "check" code.
pico:
Edit: Reading between the lines, I'm guessing you think the Serial.available() method reports on SRAM availability?
Ya that's what I was thinking and now i know I'm wrong..