Errors in Touch Capacitive Project...

I knotted up the + LED and LilyPad port connections before class.

All of my leds turned on, and are sitting there, on.  :/  my program is so simple, it is flawless!  (apparently not.)  But I know that, last week, with one alligator clip, I totes got different readings on my lovely, crunch sensors (they are inside the sleeves).
maybe it is a mis-sew on my circuit.
that could be a problem later.
Straightened it out, still solid LEDs.
In case things were touching that ought not to be, I put on my sweater.  The only times the lights go OFF is when they are pressed on the foil beneath them.  As discovered by my curious work partner.  Pressed...  hmmmm.  Well, never mind that now!   *POP* across my shoulders.  well, that's not good.  I ripped my left sleeve line trying to stretch it out to tighten, just in case that first pop wasn't a rip.  They sounded similar.  LED's still on.




I updated my sketch/program to turn the leds off no matter WHAT the level of the SV was.  still on.  Signs point to a circuit error.  However, they turned OFF when the program was uploading, so I know its probably not a sewing issue after all.

They are such beautiful little twinklies...
They aren't even TWINKLING!!!  GAH!

I will attempt to update the program on the mac lab, just in case the fault is with my PC IDE.  But, it only hiccuped once, and all the uploads were successful and quick after that!  Such a flawless performance, indeed.

ugh!
finally a justification for saving my
thread scraps.  


...'What will I ever use it for?'
Why, THIS!

><><>< 
Turns out that I didn't catch the very important part of code about defining and more defining of sensorValue.  In my defense, I missed the day the coding language/this project's code was actually explained, was sitting by two people that were as sketched out as I was, and the instructors were preoccupied helping the whole class.  (Plus I didn't stay late, because I had a dinner date!  YUM, KFC!!!)
Still, besides declaring the variable, I never defined it, and feel like I should have noticed that.  Even if I didn't know how I was supposed to.  So a little embarrassing...
So Janelle helped me out there.  
There was the issue of defining EVERY WINDOW of variable values top and bottom.  I was trying to do less than or equal to, but started out with a window, so maybe just >= (greater than) would work, but by then they were all changed to two parts, so whatever.
The lights were still being stuck to on.  I was going back and forth between commenting stuff out and not, and zeroed in on my ELSE statement.  Yeah!  little bastard, it got me at compiling, and now was keeping my lights stuck on.  I made it an ELSE IF.  Everything works like a charm.  Some blinking issues, but, eh, I think that is a short or something with the sewing.  I tried a few things with the code, didn't help.  I was super hungry and had an appointment I was gonna be late for.  So 'eh, close enough'.

Wearing the sweater while trouble shooting my code, I kept felt like I was getting jabbed or shocked where the quilting of my (+) terminals and the lily pad were, especially.  Ouch!  felt much better to take it off.  Dunno if I would add lining or just wear double layers.  Probably double layers, unless I had more iron-on stuff, fabric style.  I know my sisters were pretty wild about that for a few of my formative years.  Talking about cloth pictures on paper bags!  etc.

PS, by 'works' I mean that the lights go on, and hold, down a line depending on pressure.  Maybe I will post a video via phone.  holding the camera sort of ruined my ideal connection, so the effect was jittering/sticking, etc.

oh yeah, here is my original, broken code.

int bluea = A3;
int blueb = A2;
int greena = 11;
int greenb = 10;
int yeller= 9;
int reda = 3;
int redb = 2;
int pFoil= A5; //+ foil
int SV;  //sensor value, variable to store the value coming from the sensor

void setup()  //run once, when the sketch starts... while true function?
{
  Serial.begin(9600);//prints out the values, for debugging */

  SV = analogRead(pFoil); //read the value from the sensor. does once per loop
  pinMode(bluea,OUTPUT);
  pinMode(blueb,OUTPUT);
  pinMode(greena,OUTPUT);
  pinMode(greenb,OUTPUT);
  pinMode(yeller,OUTPUT);
  pinMode(reda,OUTPUT);
  pinMode(redb,OUTPUT);
  pinMode(pFoil,INPUT);

 }//end of void setup

  void loop()
  {
    if(SV>=995)
     {
      digitalWrite(greena,LOW);
      digitalWrite(greenb,LOW);
      digitalWrite(bluea,LOW);
      digitalWrite(blueb,LOW);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
   
     /* softGlow();// I am making a function!  see end of program.*/
      }//first if
    else if(SV<=994) //bluea 994-945
    {

      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,LOW);
      digitalWrite(greena,LOW);
      digitalWrite(greenb,LOW);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
 
    }//994-945
    else if(SV<=944) //blueb 944-895
    {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,LOW);
      digitalWrite(greenb,LOW);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
    }
    else if(SV<=894) //greena 894-845
    {
   
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,LOW);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
    }
    else if(SV<=844) //greenb 864-795
    {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,HIGH);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
    }
    else if(SV<=794) //yeller 794-745
    {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,HIGH);
      digitalWrite(yeller,HIGH);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW) ;
    }
    else if(SV<=744) //reda 744-695
    {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,HIGH);
      digitalWrite(yeller,HIGH);
      digitalWrite(reda,HIGH);
      digitalWrite(redb,LOW);
    }
    else(SV<=694); //redb 744-695-0  sooo, else
    {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,HIGH);
      digitalWrite(yeller,HIGH);
      digitalWrite(reda,HIGH);
      digitalWrite(redb,HIGH);
    }

   }//end void loop

><><><><><

And here is the fixed one

int bluea = A3;
int blueb = A2;
int greena = 11;
int greenb = 10;
int yeller= 9;
int reda = 3;
int redb = 2;
int pFoil= A5; //+ foil
int SV;  //sensor value, variable to store the value coming from the sensor

void setup()  //run once, when the sketch starts... while true function?
{
  //Serial.begin(9600);//prints out the values, for debugging */

  SV = analogRead(pFoil); //read the value from the sensor. does once per loop
  pinMode(bluea,OUTPUT);
  pinMode(blueb,OUTPUT);
  pinMode(greena,OUTPUT);
  pinMode(greenb,OUTPUT);
  pinMode(yeller,OUTPUT);
  pinMode(reda,OUTPUT);
  pinMode(redb,OUTPUT);
  pinMode(pFoil,INPUT);
  digitalWrite(pFoil, HIGH);

 }//end of void setup

  void loop()
  {
    SV=analogRead(pFoil);  //was missing these two lines.  defines SV for the loops!
 
    SV=map(SV,800,1023,1,1023);
    SV=constrain(SV,0,1023);
    //Serial.println(SV);
 //not sure what this does specifically, oh, its for the debugging sensor reader screen.
    //delay(10);

    if(SV< 1023 && SV >=950)
     {
      digitalWrite(greena,LOW);
      digitalWrite(greenb,LOW);
      digitalWrite(bluea,LOW);
      digitalWrite(blueb,LOW);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
   
     /* softGlow();// I am making a function!  see end of program.*/
      }//first if
   
    else if(SV< 935 && SV >=850) //bluea 994-945
    {

      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,LOW);
      digitalWrite(greena,LOW);
      digitalWrite(greenb,LOW);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
 
    }//994-945
 
    else if(SV< 850 && SV >=800) //blueb 944-895
    {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,LOW);
      digitalWrite(greenb,LOW);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
    }
 
    else if(SV< 800 && SV >=750) //greena 894-845
    {
   
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,LOW);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
    }
 
    else if(SV< 750 && SV >=700) //greenb 864-795
    {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,HIGH);
      digitalWrite(yeller,LOW);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW);
    }
     else if (SV < 700 && SV >=650) //yeller 794-745
    {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,HIGH);
      digitalWrite(yeller,HIGH);
      digitalWrite(reda,LOW);
      digitalWrite(redb,LOW) ;
    }
  else if (SV< 650 && SV>=500) //reda 744-695
    {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,HIGH);
      digitalWrite(yeller,HIGH);
      digitalWrite(reda,HIGH);
      digitalWrite(redb,LOW);
    }
   else if (SV< 500 && SV>=100) //redb 744-695-0  sooo, else
     {
      digitalWrite(bluea,HIGH);
      digitalWrite(blueb,HIGH);
      digitalWrite(greena,HIGH);
      digitalWrite(greenb,HIGH);
      digitalWrite(yeller,HIGH);
      digitalWrite(reda,HIGH);
      digitalWrite(redb,HIGH);
    }

   }//end void loop


/* //define functions after void setup  
  void softGlow();
  {void setup()  { 
  // nothing happens in setup 


void loop()  { 
  // fade in from min to max in increments of 5 points:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);                            
  } 

  // fade out from max to min in increments of 5 points:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);                          
  } 
} */



Comments

Popular posts from this blog

Superwomen and the "fix him" myth

Makey Makey Blog