Pages: [1]   Go Down
Author Topic: Wrong sketch?  (Read 1467 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi to all! i have an ArduinoUNO, and i tried to use this sketch, but it wont work!! why??



/*
 * WiiChuckDemo --
 *
 * 2008 Tod E. Kurt, http://thingm.com/
 *
 */

#include <Wire.h>
#include "nunchuck_funcs.h"

#include <Servo.h>

Servo olhosim;

Servo olhonao;

Servo boca;

 

int valorolhosim = 0;

int valorolhonao = 0;

int valorboca = 0;
int loop_cnt=0;

byte accx,accy,accz,zbut,cbut,joyx,joyy;
int ledPin = 13;


void setup()
{

olhosim.attach(smiley-cool;

olhonao.attach(9);

boca.attach(10);


    Serial.begin(19200);
    nunchuck_setpowerpins();
    nunchuck_init(); // send the initilization handshake
   
    Serial.print("WiiChuckDemo ready\n");
}

void loop()
{
    if( loop_cnt > 100 ) { // a cada 100ms, pegue novos dados
        loop_cnt = 0;

        nunchuck_get_data();
olhosim.write(valorolhosim);
delay(1);
olhonao.write(valorolhonao);
delay(1);
boca.write(valorboca);
 

        accx  = nunchuck_accelx();
        accy  = nunchuck_accely();
        accz  = nunchuck_accelz();
       
        zbut  = nunchuck_zbutton();
        cbut  = nunchuck_cbutton();
       
        joyy  =  nunchuck_joyy();
        joyx  =  nunchuck_joyx();

 

valorolhosim = map(joyy, 0, 250, 0, 179);
delay (1);

valorolhonao = map(joyx, 0, 250, 0, 179);
delay (1);

valorboca = map(accy, 0, 150, 0, 179);
delay (1);

        Serial.print("accx: "); Serial.print((byte)accx,DEC);
        Serial.print("\taccy: "); Serial.print((byte)accy,DEC);
        Serial.print("\taccz: "); Serial.println((byte)accz,DEC);
        Serial.print("\tzbut: "); Serial.print((byte)zbut,DEC);
        Serial.print("\tcbut: "); Serial.print((byte)cbut,DEC);
        Serial.print("\tjoyx: "); Serial.print((byte)joyx,DEC);
        Serial.print("\tjoyy: "); Serial.print((byte)joyy,DEC);
        Serial.print("\valorolhosim: ");Serial.print((byte) valorolhosim,DEC);
        Serial.print("\valorolhonao: ");Serial.print((byte) valorolhonao,DEC);
   
    }
    loop_cnt++;
    delay(1);
}


Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25804
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
it wont work!! why??
Usual questions - what does it do that it should not, and what does it not do that it should?

Please use code tags when posting code.

Code:
if( loop_cnt > 100 ) { // a cada 100ms, pegue novos dados
explain, please.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

wow!

ok, i have an arduinoUNO, and i need to control 2 servos with my wii nunchuck. I found this sketch, but i'm not able to load on my board, any suggest?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25804
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I found this sketch, but i'm not able to load on my board, any suggest?
If it won't load, it is fairly obvious that it cannot work, but you didn't say that.
What error message do you get when you try to upload?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

here are the message: "nunchuck_setpowerpins was not declared on this scope


Logged

Senago - Milano
Offline Offline
God Member
*****
Karma: 3
Posts: 508
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

just try to save this file in the same folder where you have your sketch, then close and reload

https://raw.github.com/todbot/wiichuck_adapter/master/firmware/WiichuckDemo/nunchuck_funcs.h
Logged

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

to reinforce the previous poster's message:  you are getting this error because you trying to call a function that hasn't been defined or declared...   

nunchuck_setpowerpins();

Set the "verbose" option in the IDE and look at the output, you will very likely see that the compiler is complaining at you about not being able to find the include file.
Logged

Pages: [1]   Go Up
Jump to: