Hi All,
I am new to the forum and also new to Arduino so please bare with me.I have a sketch where I am trying to get a theaterchase effect to go one way when a temperature sensor is activated and the other way when the other sensor is activated.My sketch is below but I get errors when I try to compile it i.e fast was not declared in this scope.I think it is just (punctuation) but not sure.
If anyone can help it will be very much appreciated.
Thank you in advance
#include "FastLED.h" //saved in magpi
#include <OneWire.h>
#include <DallasTemperature.h>
#define NUM_LEDS 300 //141 Reverse 150 forward
CRGB leds[NUM_LEDS];
#define PIN 6
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup()
{
sensors.setResolution(9);
sensors.begin();
FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop() {
sensors.requestTemperatures();
//Serial.print(sensors.getTempCByIndex(0));
if (sensors.getTempCByIndex(0) >= 25) {
theaterChase ;
}
if (sensors.getTempCByIndex(1) >= 25) {
fast ;
}
}
void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 6; q--) { //reverse with -- or ++
for (int i=0; i < NUM_LEDS; i=i+6) {
setPixel(NUM_LEDS-(i+q), red, green, blue); //turn every 6th pixel on
}
}
}
showStrip();
delay(60);
for (int i=0; i < NUM_LEDS; i=i+1) { // delay ?
setPixel(i+q , 0,0,0);
}
}
}
void fast(byte red, byte green, byte blue, int SpeedDelay) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 6; q++) { //reverse with -- or ++
for (int i=0; i < NUM_LEDS; i=i+6) {
setPixel(NUM_LEDS-(i+q), red, green, blue); //turn every 6th pixel on
}
}
}
}
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for (int i=NUM_LEDS; i >= 0; i=i-3) {
setPixel(i, red, green, blue);
}
showStrip();
}