small medium large xlarge

Back to: All Forums  Arduino
Generic-user-small
24 Dec 2011, 22:14
L Abdulezer (4 posts)

First let me compliment you on writing a very clearly written book. In following the example for Chapter 7 on the Nunchuk interfacing (NunchukDemo.pde) I get the following sets of problems:

“As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.”

No problem, I go ahead and make the changes from send to write in the nunchuk.cpp file, and then when I try to recompile I receive the following error message:

“call of overloaded ‘write(int)’ is ambiguous”

Can you please advise on how to correct the code?

Thanks!

Maik_schmidt_avatar2_pragsmall
25 Dec 2011, 12:08
Maik Schmidt (122 posts)

You only have to slightly change the code to make it compile.

  • Replace @#include @ with @#include @ in the first line.

  • Replace all calls to @send()@ with @write()@ and cast the argument to @byte@. For example, use @Wire.write((byte)0x40)@ instead of @Wire.send(0x40)@.

  • Replace @Wire.receive()@ with @Wire.read()@.

Cheers,

Maik

Generic-user-small
26 Dec 2011, 05:21
L Abdulezer (4 posts)

Maik,

Thank you very much. I applied the changes you suggested and it worked right away.

When I ran the code there was something rather curious… when I press the zButton, the values for both the nunchuk.z_button() and nunchuk.c_button() change from 0 to 1. Whereas when I press the cButton, only nunchuk.c_button() changes from 0 to 1. Is there the intended behavior?

Thanks to much.

Maik_schmidt_avatar2_pragsmall
26 Dec 2011, 07:11
Maik Schmidt (122 posts)

Thank you very much. I applied the changes you suggested and it worked right away.

You’re welcome!

When I ran the code there was something rather curious… when I press the zButton, the values for both the nunchuk.z_button() and nunchuk.c_button() change from 0 to 1. Whereas when I press the cButton, only nunchuk.c_button() changes from 0 to 1. Is there the intended behavior?

This is not the intended behavior. When you do not press a button the corresponding function should return 0. Otherwise, it should return 1. Did you type in the code or did you download it from the book’s web site?

Cheers,

Maik

Generic-user-small
26 Dec 2011, 16:00
L Abdulezer (4 posts)

This was the downloaded code with code changes you suggested for use with Arduino 1.0 only on the file ‘nunchuk.cpp’. The contents of theo other files nunchuk.h and NunchukDemo.ino remain unaltered.

Maik_schmidt_avatar2_pragsmall
26 Dec 2011, 19:26
Maik Schmidt (122 posts)

This is strange. I’ve tried the code with a Nunchuk a few hours ago and it worked perfectly fine. Did you double check the wiring? At http://www.flickr.com/photos/50804036@N06/5118925818/sizes/l/in/set-72157625123835529/ you can see a high-resolution photo of the final circuit.

Cheers,

Maik

Generic-user-small
26 Dec 2011, 22:59
L Abdulezer (4 posts)

I checked to see that the wiring matches up, and it does. I ran the code once more (and I literally haven’t made any changes since yesterday when i posted the last set of messages) and now it works perfectly… go figure! Well thanks for taking the time to address this. Your comments on how to adjust to the new Arduino 1.0 version were extremely helpful. Once again, I have to say your book is excellent and I am obtaining great value from it.

Generic-user-small
23 Feb 2012, 23:38
jeff cheng (3 posts)

That is very interesting. I am having same problem as Abdulezer had: when zButton is pressed, both z_button() and c_button()return “1”

like Abdulezer did, I downloaded the code, and only changed what Maid recommended. I am sure the wiring have no problem.

I guess I may just need to wait untill tomorrow like Abdulexer did to see if it would work.

Thanks

-Jeff

You must be logged in to comment