Flora and conductive fabric

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
KimD
 
Posts: 4
Joined: Sun Jan 06, 2013 11:48 pm

Flora and conductive fabric

Post by KimD »

I'm working with the Capacitive Touch with Conductive Fabric and Flora tutorial, I've copied and pasted the entire sketch into my Arduino window. When I click on "Verify", I get the following errors:

CapacitiveSensorSketch:15: error: 'CapacitiveSensor' does not name a type
CapacitiveSensorSketch.pde: In function 'void setup()':
CapacitiveSensorSketch:22: error: 'cs_9_10' was not declared in this scope
CapacitiveSensorSketch.pde: In function 'void loop()':
CapacitiveSensorSketch:32: error: 'cs_9_10' was not declared in this scope

I've tried adding a type to
CapacitiveSensor cs_9_10 = CapacitiveSensor(9,10);
but this brings up other errors...

I've had success downloading Lux Sensor code and mixing it up with the Flora LED display code, but this one is giving me trouble.
Any ideas??
thanks!

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Flora and conductive fabric

Post by adafruit_support_bill »

Looks like your Capacitive Sensor library is not installed in the correct location.
http://learn.adafruit.com/adafruit-all- ... nstall-use

KimD
 
Posts: 4
Joined: Sun Jan 06, 2013 11:48 pm

Re: Flora and conductive fabric

Post by KimD »

Oh my, you're right! I knew it had to be something simple, and I thought I'd had those libraries figured out.

thank you so much.

agustm
 
Posts: 5
Joined: Fri Jul 11, 2014 9:18 am

Re: Flora and conductive fabric

Post by agustm »

Hello,
I could not solve this same problem.
I followed the instructions to install the libraries on a Mac, and it does appear on the Examples now. However, I still get the same error:
Any suggestion? Thanks!

CapacitiveSensorSketch:12: error: 'CapacitiveSensor' does not name a type
CapacitiveSensorSketch.pde: In function 'void setup()':
CapacitiveSensorSketch:16: error: 'cs_4_2' was not declared in this scope
CapacitiveSensorSketch.pde: In function 'void loop()':
CapacitiveSensorSketch:23: error: 'cs_4_2' was not declared in this scope

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Flora and conductive fabric

Post by adafruit_support_bill »

Make sure you close all instances of the Arduino IDE and then re-open it. The IDE does not recognize libraries that are installed while it is running.

User avatar
kristenw
 
Posts: 10
Joined: Sat Nov 16, 2013 2:23 pm

Re: Flora and conductive fabric

Post by kristenw »

I've wired the circuit correctly, and I've uploaded the code from

https://learn.adafruit.com/capacitive-t ... flora/code

and I keep getting the error
"RGBPixel does not name a type"
sketch_aug30b.ino:2:33: error: Adafruit_FloraPixel.h: No such file or directory
sketch_aug30b:18: error: 'RGBPixel' does not name a type
sketch_aug30b:18: error: 'Adafruit_FloraPixel' does not name a type
sketch_aug30b.ino: In function 'void setup()':
sketch_aug30b:24: error: 'strip' was not declared in this scope
sketch_aug30b.ino: In function 'void loop()':
sketch_aug30b:38: error: 'strip' was not declared in this scope
sketch_aug30b:38: error: 'Color' was not declared in this scope
sketch_aug30b:41: error: 'strip' was not declared in this scope
sketch_aug30b:41: error: 'Color' was not declared in this scope
sketch_aug30b.ino: At global scope:
sketch_aug30b:58: error: 'RGBPixel' does not name a type


What did I do wrong?

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Flora and conductive fabric

Post by adafruit_support_bill »

sketch_aug30b.ino:2:33: error: Adafruit_FloraPixel.h: No such file or directory
sketch_aug30b:18: error: 'RGBPixel' does not name a type
The compiler was not able to find the library in the expected location. Follow the instructions here to make sure that your library is installed correctly.
http://learn.adafruit.com/adafruit-all- ... nstall-use

User avatar
kristenw
 
Posts: 10
Joined: Sat Nov 16, 2013 2:23 pm

Re: Flora and conductive fabric

Post by kristenw »

Thank you, I went back, deleted my old capacitive sensor libraries, uploaded the new one from the Arduino website, made sure they were in the right location (on my Mac, documents>Arduino>libraries), and did not alter the name beyond changing - to _. I also made certain to quit the IDE program while I did all of this.

It still reads "Capacitive sensor does not name a type" when I compile. I feel like a dunce.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Flora and conductive fabric

Post by adafruit_support_rick »

Please post the exact error messages. Also run Grab and post a screenshot of the Finder showing your folder structure for the capacitive touch files

User avatar
kristenw
 
Posts: 10
Joined: Sat Nov 16, 2013 2:23 pm

Re: Flora and conductive fabric

Post by kristenw »

Screen cap.tiff
Screen cap.tiff (536.89 KiB) Viewed 1154 times
Screen cap.tiff
Screen cap.tiff (536.89 KiB) Viewed 1154 times
The errors are:

'RGBPixel' does not name a type (in the big orange block)
sketch_aug30g.ino:2:33: error: Adafruit_FloraPixel.h: No such file or directory
sketch_aug30g:18: error: 'RGBPixel' does not name a type
sketch_aug30g:18: error: 'Adafruit_FloraPixel' does not name a type
sketch_aug30g.ino: In function 'void setup()':
sketch_aug30g:24: error: 'strip' was not declared in this scope
sketch_aug30g.ino: In function 'void loop()':
sketch_aug30g:38: error: 'strip' was not declared in this scope
sketch_aug30g:38: error: 'Color' was not declared in this scope
sketch_aug30g:41: error: 'strip' was not declared in this scope
sketch_aug30g:41: error: 'Color' was not declared in this scope
sketch_aug30g.ino: At global scope:
sketch_aug30g:58: error: 'RGBPixel' does not name a type


I was able to get the pixel to light with the conductive fabric by using this code from instructables, which worked great:

Code: Select all

#include <Adafruit_NeoPixel.h>
#include <CapacitiveSensor.h>

#define PIN 6


// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(2, PIN, NEO_GRB + NEO_KHZ800);
CapacitiveSensor   cs_9_10 = CapacitiveSensor(9,10);  

void setup() {
  cs_9_10.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
  Serial.begin(9600);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  long total1 =  cs_9_10.capacitiveSensor(30);
  Serial.println(total1);

  // Some example procedures showing how to display to the pixels:
  //colorWipe(strip.Color(0, 0, 0), 50); // Red
  //colorWipe(strip.Color(0, 255, 0), 50); // Green
  //colorWipe(strip.Color(0, 0, 255), 50); // Blue
  //rainbow(20);
  //rainbowCycle(20);

  if(total1 <= 50){
    // turn LED on:
    colorWipe(strip.Color(0, 0, 0), 0);   
  }
  else {
    //turn LED off:
    colorWipe(strip.Color(255,255,255), 0);
  }
  
 //Serial.println(total1);
 //delay(100);
}




// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Flora and conductive fabric

Post by adafruit_support_rick »

kristenw wrote:sketch_aug30g.ino:2:33: error: Adafruit_FloraPixel.h: No such file or directory
You have no library named Adafruit_FloraPixel. Your sketch is trying to #include <Adafruit_FloraPixel.h>, and that file does not exist. You need to install that library.

User avatar
kristenw
 
Posts: 10
Joined: Sat Nov 16, 2013 2:23 pm

Re: Flora and conductive fabric

Post by kristenw »

THANK YOU!!

User avatar
clusey
 
Posts: 2
Joined: Thu Oct 23, 2014 1:25 pm

Re: Flora and conductive fabric

Post by clusey »

Hi! I'm having a similar problem (trying to do this exercise: https://learn.adafruit.com/capacitive-t ... -and-flora), but with v2 neopixels. I've figured out to use the Adafruit_NeoPixel.h library (versus Adafruit_FloraPixel.h) and I changed

Adafruit_FloraPixel strip = Adafruit_FloraPixel(1);

to

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, NEO_GRB + NEO_KHZ800);

I copied that over from the strandtest, minus the PIN part (not sure that's correct, just trying anything I could think of). My error messages are primarily "'Color' was not declared in this scope" and "'RGBPixel' does not name a type." I'm assuming it's related to the example code referring to FloraPixel.h and me using (and including) NeoPixel.h?

Just in the interest of trying to get rid of error message, I deleted this part completely:

Code: Select all

// Create a 24 bit color value from R,G,B
RGBPixel Color(byte r, byte g, byte b)
{
  RGBPixel p;
  
  p.red = r;
  p.green = g;
  p.blue = b;
  
  return p;
}
And changed

Code: Select all

if (total1 > 4000){
  digitalWrite(7, HIGH);
  strip.setPixelColor(0, Color(0,255,0));  
  strip.show();
} else {
  strip.setPixelColor(0, Color(0,0,0)); 
  strip.show();
}

to

Code: Select all

if (total1 > 4000){
  digitalWrite(7, HIGH);
  strip.setPixelColor(0, 0,255,0);  
  strip.show();
} else {
  strip.setPixelColor(0, 0,0,0); 
  strip.show();
}
At that point I can run the exercise and the serial monitor shows a change when I touch the conductive fabric (yay!), but the LED doesn't do anything of course (and I know it's working because I've run the strandtest with no problem).

Basically if anyone can tell me how to code the Flora/Conductive fabric exercise with V2 I would be most appreciative. My assumption (I'm totally new at this, though) is that 'color' is set differently for V2 than regular neopixels?

Thank you!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Flora and conductive fabric

Post by adafruit_support_rick »

You need to specify the PIN in the NeoPixel declaration. Do you have the pixel connected to pin D6?

The Color function was added to the NeoPixel library, so you call it with strip.Color. You can delete the Color function from the sketch

The following code has the correctchanges and should work for you:

Code: Select all

#include <CapacitiveSensor.h>
#include <Adafruit_NeoPixel.h>

#define PIN 6


/*
 * CapitiveSense Library Demo Sketch
 * Paul Badger 2008
 * Uses a high value resistor e.g. 10M between send pin and receive pin
 * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
 * Receive pin is the sensor pin - try different amounts of foil/metal on this pin
 * Modified by Becky Stern 2013 to change the color of one RGB Neo Pixel based on touch input
 */


CapacitiveSensor   cs_9_10 = CapacitiveSensor(9,10);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
//CapacitiveSensor   cs_9_2 = CapacitiveSensor(9,2);        // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
//CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8);        // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

void setup()                    
{
   cs_9_10.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   Serial.begin(9600);
    strip.begin();
    strip.show();

}

void loop()                    
{
    long start = millis();
    long total1 =  cs_9_10.capacitiveSensor(30);
    //long total2 =  cs_9_2.capacitiveSensor(30);
    //long total3 =  cs_4_8.capacitiveSensor(30);

if (total1 > 4000){
  digitalWrite(7, HIGH);
  strip.setPixelColor(0, strip.Color(0,255,0));  
  strip.show();
} else {
  strip.setPixelColor(0, strip.Color(0,0,0)); 
  strip.show();
}
  
    Serial.print(millis() - start);        // check on performance in milliseconds
    Serial.print("\t");                    // tab character for debug windown spacing

    Serial.println(total1);                  // print sensor output 1
    //Serial.print("\t");
    //Serial.println(total2);                  // print sensor output 2
    //Serial.print("\t");
    //Serial.println(total3);                // print sensor output 3

    delay(10);                             // arbitrary delay to limit data to serial port 
}

User avatar
clusey
 
Posts: 2
Joined: Thu Oct 23, 2014 1:25 pm

Re: Flora and conductive fabric

Post by clusey »

Thank you so much, Rick! That was exactly what I needed to get started & understand what was going on.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”