Go Down

Topic: Seeking a programmer for a simple job with sensors and LED tape (Read 796 times) previous topic - next topic

A_Face

Hi there!  I am attempting to finish a project similar to the one found here: https://create.arduino.cc/projecthub/gatoninja236/motion-controlled-color-changer-299217

The main difference is that I am using 3 wire LED tape with a data pin instead of an analog 4 pin single LED.  The sensor is still the same (APDS 9960) and the board is an Arduino Uno.  Basically I want to be able to swipe right to go through the colors of the rainbow in order (ROYGBIV) and swipe left to go through them in reverse order.  I do not even need the LEDs to turn on or off.

For someone that doesn't code or really do anything computer science oriented, I feel like I've gotten far enough without help to give myself a pat on the back, but unfortunately a pat on the back will not help me finish this project in time!  I have a deadline I am trying to meet, so I think it's time to just hire a coder.  I took the code from the project in the link and have been trying to combine it with code from NeoPixel libraries. 

Here is what I have so far:
Code: [Select]

#include <Wire.h>
#include <FastLED.h>
#include <Adafruit_NeoPixel.h>

// How many leds in your strip?
#define NUM_LEDS 60

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 6
#define CLOCK_PIN 13

// Define the array of leds
CRGB leds[NUM_LEDS];

#include <Wire.h>
#include <SparkFun_APDS9960.h>

// Pins
#define APDS9960_INT    2 // Needs to be an interrupt pin

// Constants

int onOff_flag = 0;

//Make the array to loop through
int colorNumber = 0;

// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;

void setup() {

  // Set interrupt pin as input
  pinMode(APDS9960_INT, INPUT);

  // Initialize Serial port
  Serial.begin(9600);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("SparkFun APDS-9960 - GestureTest"));
  Serial.println(F("--------------------------------"));
 
  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);

  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }
 
  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
    Serial.println(F("Gesture sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during gesture sensor init!"));
  }
    pinMode(DATA_PIN 6, OUTPUT);
   
      // Uncomment/edit one of the following lines for your leds arrangement.
      // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
      FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
      // FastLED.addLeds<APA104, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
     
      // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<P9813, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<APA102, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<DOTSTAR, RGB>(leds, NUM_LEDS);

      // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<P9813, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
}

void loop() {
  if( isr_flag == 1 ) {
    detachInterrupt(0);
    handleGesture();
    isr_flag = 0;
    attachInterrupt(0, interruptRoutine, FALLING);
  }
  if (onOff_flag == 1){
  switch (colorNumber){
    case 0:
    Serial.println("red");
      colorWipe(strip.Color(255, 0, 0), 50); // Red
      break;
    case 1:
    Serial.println("blue");
      colorWipe(strip.Color(0, 0, 255), 50); // Blue
      break;

void interruptRoutine() {
  isr_flag = 1;
}



Error messages are as follows:
Code: [Select]

Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Board: "Arduino/Genuino Uno"

In file included from C:\Users\amand\Documents\Arduino\Gesture_Sensor\Gesture_Sensor_LEDStrip_v1\Gesture_Sensor_LEDStrip_v1.ino:2:0:

C:\Users\amand\Documents\Arduino\libraries\FastLED-master/FastLED.h:14:21: note: #pragma message: FastLED version 3.002.001

 #    pragma message "FastLED version 3.002.001"

                     ^

C:\Users\amand\Documents\Arduino\Gesture_Sensor\Gesture_Sensor_LEDStrip_v1\Gesture_Sensor_LEDStrip_v1.ino: In function 'void setup()':

Gesture_Sensor_LEDStrip_v1:47:22: error: 'interruptRoutine' was not declared in this scope

   attachInterrupt(0, interruptRoutine, FALLING);

                      ^

Gesture_Sensor_LEDStrip_v1:62:22: error: expected ')' before numeric constant

     pinMode(DATA_PIN 6, OUTPUT);

                      ^

C:\Users\amand\Documents\Arduino\Gesture_Sensor\Gesture_Sensor_LEDStrip_v1\Gesture_Sensor_LEDStrip_v1.ino: In function 'void loop()':

Gesture_Sensor_LEDStrip_v1:96:19: error: 'handleGesture' was not declared in this scope

     handleGesture();

                   ^

Gesture_Sensor_LEDStrip_v1:98:24: error: 'interruptRoutine' was not declared in this scope

     attachInterrupt(0, interruptRoutine, FALLING);

                        ^

Gesture_Sensor_LEDStrip_v1:104:17: error: 'strip' was not declared in this scope

       colorWipe(strip.Color(255, 0, 0), 50); // Red

                 ^

Gesture_Sensor_LEDStrip_v1:104:43: error: 'colorWipe' was not declared in this scope

       colorWipe(strip.Color(255, 0, 0), 50); // Red

                                           ^

Gesture_Sensor_LEDStrip_v1:111:25: error: a function-definition is not allowed here before '{' token

 void interruptRoutine() {

                         ^

Gesture_Sensor_LEDStrip_v1:113:1: error: expected '}' at end of input

 }

 ^

Gesture_Sensor_LEDStrip_v1:113:1: error: expected '}' at end of input

Gesture_Sensor_LEDStrip_v1:113:1: error: expected '}' at end of input

exit status 1
'interruptRoutine' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


I feel like a lot of these mistakes are grammatical, but the biggest thing I can't figure out is the interruptRoutine not being declared...I've looked through several different APDS 9960 projects at this point and I'm not sure what I need to do differently.

Please PM me with a quote for your services and I'll be happy to pay you a fair rate in order to meet my deadline. Comment if you have any questions about the project and I'll be happy to answer them.

wvmarle

Code: [Select]

     pinMode(DATA_PIN 6, OUTPUT);

This is obviously wrong. Fix it (remove the 6) and fair chance the rest of the code compiles as well.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

A_Face

Gotcha. Thanks for looking at this. I removed the 6 but am still getting several errors, including that the interruptRoutine hasn't been defined. Any ideas there?

arduarn

You are missing 3 closing braces  } at the end of your loop() but before interruptRoutine().
You are also missing the handleGesture() function that was in the link you posted.

But unfortunately there looks to be other errors too.

wvmarle

to find closing braces use the autoformat of the IDE (ctrl-T key combination or somewhere in the menu). That helps a lot spotting those errors.

After that, start with the first error the IDE indicates, and fix it. Then try to compile again. More often than not a single typo gives rise to more than one error message.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up