Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumWiring HardwareTangible computing › qslide doesn't work

Page Index Toggle Pages: 1
qslide doesn't work (Read 7196 times)
08/16/06 at 13:01:51

kimhaemin   Offline
YaBB Newbies
kimhaemin.info
Seoul, South Korea

Posts: 4
*
 
I made a prototype model for my assignment.

---> prototype model movie
http://kimhaemin.info/test/final/movie_final.mov

I used my laptop trackpad for touch sensor(serial from processing).

But I want to use Qslide touch sensor.

I attatched QSlide sensor to board and uploaded source code below,

but it doesn't work(even LED doesn't light up).

Please, help me~~^0^



float tval0 = 0;
float value0 = 0;                            // variable to keep the actual value
float tval1 = 0;
float value1 = 0;                            // variable to keep the actual value
float tval2 = 0;
float value2 = 0;                            // variable to keep the actual value
float tval3 = 0;
float value3 = 0;                            // variable to keep the actual value
float tval4 = 0;
float value4 = 0;                            // variable to keep the actual value
float tval5 = 0;
float value5 = 0;                            // variable to keep the actual value
int x;

QSlide slider = QSlide(2, 6, 4, 5, 3, 7, 8);
void setup()
{
  pinMode(48,OUTPUT);
  digitalWrite(48,HIGH);
  Serial.begin(9600); 
}

void loop()
{
 
  if(slider.isTouching())  // if someone is touching the slider
   {
   digitalWrite(48,HIGH);
   x = slider.read(); // read the slider as an integer
   //Serial.print(x);       // print via serial port
   }
   


  if (x>10 && x <30)
  {
    tval0 = 255;
    tval1 = 0;
    tval2 = 0;
    tval3 = 0;
    tval4 = 0;
    tval5 = 0;

  }
  else if (x>30 && x<50) {

    tval1 = 255;
    tval0 = 0;
    tval2 = 0;
    tval3 = 0;
    tval4 = 0;
    tval5 = 0;

  }
  else if (x>50 && x<70) {
    tval2 = 255;
    tval1 = 0;
    tval0 = 0;
    tval3 = 0;
    tval4 = 0;
    tval5 = 0;
  }
  else if (x>70 && x<90) {
    tval3 = 255;
    tval1 = 0;
    tval2 = 0;
    tval0 = 0;
    tval4 = 0;
    tval5 = 0;
  }
  else if (x>90 && x<110) {
    tval4 = 255;
    tval1 = 0;
    tval2 = 0;
    tval3 = 0;
    tval0 = 0;
    tval5 = 0;
  }
  else if (x>110 && x<130) {
    tval5 = 255;
    tval1 = 0;
    tval2 = 0;
    tval3 = 0;
    tval4 = 0;
    tval0 = 0;
  }
 
  else if (x < 10) {
    tval0 = 0;
    tval1 = 0;
    tval2 = 0;
    tval3 = 0;
    tval4 = 0;
    tval5 = 0;
  }
 
  else if (x > 130) {
    tval0 = 0;
    tval1 = 0;
    tval2 = 0;
    tval3 = 0;
    tval4 = 0;
    tval5 = 0;
  }
 
  value0 = value0+(tval0-value0)*0.05;
  value1 = value1+(tval1-value1)*0.05;
  value2 = value2+(tval2-value2)*0.05;
  value3 = value3+(tval3-value3)*0.05;
  value4 = value4+(tval4-value4)*0.05;
  value5 = value5+(tval5-value5)*0.05;


  analogWrite(0, value0);
  analogWrite(1, value1);
  analogWrite(2, value2);
  analogWrite(3, value3);
  analogWrite(4, value4);
  analogWrite(5, value5);
  delay(10);

}
 

kimhaemin.info
IP Logged
 
Reply #1 - 08/16/06 at 22:39:12

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Could you provide information on your circuit as well? there is a Wiring board illustrator file here http://wiring.org.co/ioboard/WIRINGBOARD.zip

 
IP Logged
 
Reply #2 - 09/03/06 at 10:40:24

kimhaemin   Offline
YaBB Newbies
kimhaemin.info
Seoul, South Korea

Posts: 4
*
 
http://kimhaemin.info/test/final/img/wiring_tactualight.jpg

This is a plan of my work.

 

kimhaemin.info
IP Logged
 
Reply #3 - 09/07/06 at 14:17:03

tokage   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 1
*
 
I found example of QSlide on Arduino site : http://www.arduino.cc/en/Tutorial/Qt401
I modified some code for wiring, and it works fine.


// define pin mapping
int qt401_drd = 2; // data ready
int qt401_di  = 3; // data in (from sensor)
int qt401_ss  = 4; // slave select
int qt401_clk = 5; // clock
int qt401_do  = 6; // data out (to sensor)
int qt401_det = 7; // detect
int qt401_prx = 8; // proximity  

byte result;

void qt401_init() {
 // define pin directions
 pinMode(qt401_drd, INPUT);
 pinMode(qt401_di,  INPUT);
 pinMode(qt401_ss,  OUTPUT);
 pinMode(qt401_clk, OUTPUT);
 pinMode(qt401_do,  OUTPUT);
 pinMode(qt401_det, INPUT);
 pinMode(qt401_prx, INPUT);

 // initialise pins
 digitalWrite(qt401_clk,HIGH);
 digitalWrite(qt401_ss, HIGH);
}

//
//  wait for the qt401 to be ready
//
void qt401_waitForReady(void)
{
 while(!digitalRead(qt401_drd)){
   continue;
 }
}

//
//  exchange a byte with the sensor
//

byte qt401_transfer(byte data_out)
{
 byte i = 8;

 byte mask = 0;
 byte data_in = 0;

 digitalWrite(qt401_ss,LOW); // select slave by lowering ss pin
 delayMicroseconds(75); //wait for 75 microseconds

 while(0 < i) {

   mask = 0x01 << --i; // generate bitmask for the appropriate bit MSB first

   // set out byte
   if(data_out & mask){ // choose bit

     digitalWrite(qt401_do,HIGH); // send 1

   }
   else{

     digitalWrite(qt401_do,LOW); // send 0

   }

   // lower clock pin, this tells the sensor to read the bit we just put out
   digitalWrite(qt401_clk,LOW); // tick

   // give the sensor time to read the data

   delayMicroseconds(75);

   // bring clock back up

   digitalWrite(qt401_clk,HIGH); // tock

   // give the sensor some time to think

   delayMicroseconds(20);

   // now read a bit coming from the sensor
   if(digitalRead(qt401_di)){

     data_in |= mask;

   }

   //  give the sensor some time to think

     delayMicroseconds(20);

 }

 delayMicroseconds(75); //  give the sensor some time to think
 digitalWrite(qt401_ss,HIGH); // do acquisition burst

 return data_in;
}

void qt401_calibrate(void)
{
 // calibrate
 qt401_waitForReady();
 qt401_transfer(0x01);
 delay(600);

 // calibrate ends
 qt401_waitForReady();
 qt401_transfer(0x02);
 delay(600);
}  


void qt401_setProxThreshold(byte amount)
{
 qt401_waitForReady();
 qt401_transfer(0x40 & (amount & 0x3F));
}


void qt401_setTouchThreshold(byte amount)
{
 qt401_waitForReady();
 qt401_transfer(0x80 & (amount & 0x3F));
}


byte qt401_driftCompensate(void)
{
 qt401_waitForReady();
 return qt401_transfer(0x03);
}


byte qt401_readSensor(void)
{

 qt401_waitForReady();
 return qt401_transfer(0x00);
}  


void setup() {

 //setup the sensor
 qt401_init();
 qt401_calibrate();
 qt401_setProxThreshold(10);
 qt401_setTouchThreshold(10);

 Serial.begin(4800);
 pinMode(48,OUTPUT);
 digitalWrite(48,HIGH);
}


void loop() {

 if(digitalRead(qt401_det)){
   result = qt401_readSensor();

   if(0x80 & result){
     result = result & 0x7f;
     
     // print to LCD display
     Serial.print(char(0x1b));
     Serial.print("H");
     Serial.print(int(result));

   }
 }
//  delay(2);
}
 
IP Logged
 
Reply #4 - 09/07/06 at 19:09:48

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
The library should work fine, I got a QSilde so I can run some tests and get back to you.
 
IP Logged
 
Reply #5 - 09/24/06 at 19:41:20

zambetti   Offline
YaBB Newbies

Posts: 21
*
 
kimhaemin, this might sound a bit obvious ... but your illustration doesn't indicate that the GND and +5V of the Qslide sensor are connected ... did you just forget to draw them on the diagram?
 
IP Logged
 
Reply #6 - 09/26/06 at 16:49:06

kimhaemin   Offline
YaBB Newbies
kimhaemin.info
Seoul, South Korea

Posts: 4
*
 
I just forgot draw GND in illustration.

But when I tested, I connected GND and Qslide sensor.
 

kimhaemin.info
IP Logged
 
Reply #7 - 10/07/06 at 05:14:45

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Dear Kimhaemin, wiring-0009 is up with the needed fixes. Please let us know.
« Last Edit: 10/21/06 at 05:31:31 by barragan »  
IP Logged
 
Page Index Toggle Pages: 1