I have arduino leonardo and I would like to know if someone see's the problem with this code. It doesn't show anything on the serial monitor for me. Logically, it's supposed to show me the result under the code. However, it's not and I don't know why.
and I don't see my mistake. Maybe it's some declaration that I forgot to in leonardo because I am adapting the code from arduino uno to leonardo. If you see the problem, please infom me what it is
thank you
You didn't bother to tell us what the code actually DOES do, but....
On the FIRST call to strtok, you should be passing a pointer to the string to be parsed as the first argument. All subsequent calls should be passing NULL as the first argument, so it will continue to parse from where it left off. The code that you have ALWAYS starts at the beginning of the string, so it will NEVER parse beyond the first delimiter, and that first delimiter gets replaced with a '\0' on the first call to strtok.
Why have you #defined names for the serial interfaces ?
What happens if you use their normal names ?
The code should not need to be adapted to run on a Leonardo beyond ensuring that the Serial interface, note, not Serial1, is ready before sending serial data to it.
while (!Ser1) { }I think that you are waiting fro the wrong serial interface to be available and you don't use Serial1 anywhere in your program anyway.
Does a simple "Hello World" program print on the serial monitor ?
UKHeliBob:
Why have you #defined names for the serial interfaces ?
What happens if you use their normal names ?
same
UKHeliBob:
The code should not need to be adapted to run on a Leonardo beyond ensuring that the Serial interface, note, not Serial1, is ready before sending serial data to it.
What should I do to correct?
UKHeliBob: while (!Ser1) { }I think that you are waiting fro the wrong serial interface to be available and you don't use Serial1 anywhere in your program anyway.
even if I try while (!Ser) { } , it still gives me the same thing
UKHeliBob:
Does a simple "Hello World" program print on the serial monitor ?
non, it's supposed to print automatically. and even if i send "hello world" nothing prints on the serial monitor
RayLivingston:
You didn't bother to tell us what the code actually DOES do, but....
On the FIRST call to strtok, you should be passing a pointer to the string to be parsed as the first argument. All subsequent calls should be passing NULL as the first argument, so it will continue to parse from where it left off. The code that you have ALWAYS starts at the beginning of the string, so it will NEVER parse beyond the first delimiter, and that first delimiter gets replaced with a '\0' on the first call to strtok.
Robin2:
The parse example in Serial Input Basics includes strtok() in the example.
...R
That one is for UNO and needs to be adapted to leonardo. I am looking for a code with Arduino leonardo. I think that my probem is to adapt from uno to leonardo. However, changing the variables like I used to do don't work now.