fsr>neopixel strip

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
roxanne
 
Posts: 9
Joined: Wed Dec 03, 2014 11:30 pm

fsr>neopixel strip

Post by roxanne »

hello! I am not very good with coding, but I am working on a project where I am connecting an FSR sensor to a neopixel strip. It's pretty simple: when weight is applied, the strip does its crawling rainbow effect. when weight is lifted, the lights, obviously, go off

I am not sure how to code the setup, letting my arduino know of the sensor and lighting up the strip, then loop ... help? please!! :)

thanks!

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

Re: fsr>neopixel strip

Post by adafruit_support_bill »

I'd start by connecting up the FSR and testing to make sure it is working. Have you run the code from the tutorial?
https://learn.adafruit.com/force-sensit ... ing-an-fsr

User avatar
roxanne
 
Posts: 9
Joined: Wed Dec 03, 2014 11:30 pm

Re: fsr>neopixel strip

Post by roxanne »

Yes, it seems to all work fine. Now just the setup code is what I am having trouble with accurately including the pressure sensor into the rainbow code

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

Re: fsr>neopixel strip

Post by adafruit_support_bill »

Yes, it seems to all work fine.
So open the serial monitor and observe the output as you press on the FSR. Find the level of pressure that you want to trigger the led strip and remember that number. Then you can test for that in your code and use it to trigger the RainbowCycle from the NeoPixel StrandTest example.

Code: Select all

  
fsrReading = analogRead(fsrAnalogPin);
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);

  if (fsrReading > 500)  // when pressure is greater than threshold
  {
    rainbowCycle(5);   // rainbow cycle
  }

User avatar
roxanne
 
Posts: 9
Joined: Wed Dec 03, 2014 11:30 pm

Re: fsr>neopixel strip

Post by roxanne »

So I think for the most part I have to declare the rainbowcycle in the scope, not sure how to work on that one. I really appreciate all your help, hope I'm not asking too much at this point !! :)

Code: Select all

#include <Adafruit_NeoPixel.h>

int fsrPin = 0;
int fsrReading;

void setup(void) {
    Serial.begin(9600);   
}

Adafruit_NeoPixel  strip = Adafruit_NeoPixel(60, 6, NEO_GRB + NEO_KHZ800);

void loop() {
  fsrReading = analogRead(fsrAnalogPin);
  
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);

  if (fsrReading > 240)  // when pressure is greater than threshold
  {
    rainbowCycle(5);   // rainbow cycle
  }
}

void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}
Errors:

Arduino: 1.6.3 (Windows 7), Board: "Arduino Uno"

sketch_apr29b.ino: In function 'void loop()':

sketch_apr29b.ino:13:27: error: 'fsrAnalogPin' was not declared in this scope

sketch_apr29b.ino: In function 'void rainbowCycle(uint8_t)':

sketch_apr29b.ino:29:77: error: 'Wheel' was not declared in this scope

Error compiling.

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

Re: fsr>neopixel strip

Post by adafruit_support_bill »

sketch_apr29b.ino:13:27: error: 'fsrAnalogPin' was not declared in this scope
You have it declared as "fsrPin". Change one or the other so that they agree.
sketch_apr29b.ino:29:77: error: 'Wheel' was not declared in this scope
You will need to copy the Wheel function from strandTest into your sketch also.

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

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”