Go Down

Topic: Wii camera demo + digitalpot's problem continues. (Read 1 time) previous topic - next topic


It works ! kinda !!
OK, after some real head banging and coding issues I finally am getting some where, or so I thought...
Using wiimote ir camera hack and the AD5206 Digital pot to control my xbox wired controller I have hit another problem ! After being helped by a great guy with the code I find that I only get the X axis to work (ie Left /right)
the Y axis still refuses to work (up and down), I see in the serial monitor that it is functioning fine, but get nothing,
no voltage output from the digi-pot (channel 2), I have check the wiring etc , and even reolaced the digi-pot,
I have even re-wired it so that the X axis wiper wire controls  the Y axis on the xbox controller ,  it works! I have tried a different channel too, still nothing!  So I'm thinking maybe it's still a coding issue, so again here is the code I have, Am I just missing something ??? Can some one have a look  PLEASE, before I go mad !!

Code: [Select]

#include <Wire.h>
#include <PVision.h>
#include <SPI.h>
//Select one of the following to be 0, and the other 1
//'0': ON, '1': OFF
#define serial_display 1
#define processing_display 0

#define channelx 1
#define channely 2
PVision ircam;
byte result;

// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;
int digpot_x = 500;
int digpot_y = 500;

//MUX testing
int S0 = 5;
int S1 = 6;
void setup()
   // while (Serial.available() <= 0) {
     //Serial.print("AE v1.0");   // send a capital A
    // delay(300);
//SPI stuff here
   pinMode (slaveSelectPin, OUTPUT);

void loop()
  result = ircam.read();
  if(serial_display == 1){
    if (result & BLOB1)
      digpot_x = ircam.Blob1.X >> 2;
      digpot_y = ircam.Blob1.Y >> 2;
      Serial.print("BLOB1 detected. X:");
      Serial.print(" Y:");
      Serial.print(" Size:");
    if (result & BLOB2)
      Serial.print("BLOB2 detected. X:");
      Serial.print(ircam.Blob2.X >> 2);
      Serial.print(" Y:");
      Serial.print(ircam.Blob2.Y >> 2);
      Serial.print(" Size:");
    if (result & BLOB3)
      Serial.print("BLOB3 detected. X:");
      Serial.print(ircam.Blob3.X >> 2);
      Serial.print(" Y:");
      Serial.print(ircam.Blob3.Y >> 2);
      Serial.print(" Size:");
    if (result & BLOB4)
      Serial.print("BLOB4 detected. X:");
      Serial.print(ircam.Blob4.X >> 2);
      Serial.print(" Y:");
      Serial.print(ircam.Blob4.Y >> 2);
      Serial.print(" Size:");
     digitalPotWrite (channelx,(int)digpot_x);
     digitalPotWrite (channely,(int)digpot_y);
  }//endif serial_display
  else if(processing_display == 1){
    if( Serial.available() > 0){
   //   print header
     uint8_t XL1 = ircam.Blob1.X & 0xFF;
     uint8_t XH1 = (ircam.Blob1.X >> 8) & 0x03;
     uint8_t YL1 = ircam.Blob1.Y & 0xFF;
     uint8_t YH1 = (ircam.Blob1.Y >> 8) & 0x03;
     uint8_t XL2 = ircam.Blob2.X & 0xFF;
     uint8_t XH2 = (ircam.Blob2.X >> 8) & 0x03;
     uint8_t YL2 = ircam.Blob2.Y & 0xFF;
     uint8_t YH2 = (ircam.Blob2.Y >> 8) & 0x03;

    }//end ifSerial.available
  }//endif processing_display

}//End loop()

void digitalPotWrite(int address, int value) {
   // take the SS pin low to select the chip:
   //  send in the address and value via SPI:
   // take the SS pin high to de-select the chip:

:smiley-roll: Thanks !!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131