matpi / EmbeddedSystemsUTU

This repository concerns the course KSA4 Embedded Systems (craft, design and technology education) in the University of Turku, Department of Teacher Education, Rauma Unit in the academic year 2014
4 stars 5 forks source link

Nunchuk koodi ei oikein toimi #33

Open SiiriKnuuttila opened 9 years ago

SiiriKnuuttila commented 9 years ago

Kytkimme Nunchukin i2c protokollan mukaisesti A4 ja A5 pinneihin. Latasimme Arduinon Nunchuck esimerkin, joka näyttää jotenkin vajaalta:

include

include

define BAUDRATE 19200

ArduinoNunchuk nunchuk = ArduinoNunchuk();

void setup() { Serial.begin(BAUDRATE); nunchuk.init(); }

void loop() { nunchuk.update();

Serial.print(nunchuk.analogX, DEC); Serial.print(' '); delay(100); Serial.print(nunchuk.analogY, DEC); Serial.print(' '); delay(100); Serial.print(nunchuk.accelX, DEC); Serial.print(' '); delay(100); Serial.print(nunchuk.accelY, DEC); Serial.print(' '); delay(100); Serial.print(nunchuk.accelZ, DEC); Serial.print(' '); delay(100); Serial.print(nunchuk.zButton, DEC); Serial.print(' '); delay(100); Serial.println(nunchuk.cButton, DEC); }

nuch_koodi

Serial monitori näyttää tosi epämääräistä dataa... mikähän tässä on? Onko kirjastossa jotain vikaa?

Robojuchen commented 9 years ago

laittakaa baudrate oikeaksi sarjamonitorista, tai vaihtoehtoisesti säätä koodista baudratea eli lähetysnopeutta. nyt se on asetettu koodissa 19200 bps