I have never worked with code or anything like it until about a month and a half ago. I am writing this code to be triggered by inputs to turn specific light sequences on. Any help in what I have wrong would be greatly appreciated! I am going to copy what I have here and hopefully someone can point out what I have wrong and help me fix it.
#include "FastLED.h"
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 100
#define DATA_PIN0 11
#define DATA_PIN1 10
#define DATA_PIN2 9
#define DATA_PIN3 13
#define CHIPSET WS2811
#define BRIGHTNESS 200
#define ON 1
#define OFF 0
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<CHIPSET, DATA_PIN3>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
FastLED.show();
}
void switchInput(int inputOne, int inputTwo, int inputThree) {
if (digitalRead(inputOne) == ON && digitalRead(inputTwo) == OFF && digitalRead(inputThree) == OFF) {
for (int i = 0; i < NUM_LEDS; i++)
leds[i] = CRGB::Red;
FastLED.show();
}
if (digitalRead(inputOne) == OFF && digitalRead(inputTwo) == ON && digitalRead(inputThree) == OFF) {
for (int i = 0; i < NUM_LEDS; i++)
leds[i] = CRGB::Green;
FastLED.show();
}
if (digitalRead(inputOne) == OFF && digitalRead(inputTwo) == OFF && digitalRead(inputThree) == ON) {
void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
int Position=0;
for(int j=0; j<NUM_LEDS*2; j++)
{
Position++; // = 0; //Position + Rate;
for(int i=0; i<NUM_LEDS; i++) {
// sine wave, 3 offset waves make a rainbow!
//float level = sin(i+Position) * 127 + 128;
//setPixel(i,level,0,0);
//float level = sin(i+Position) * 127 + 128;
setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
((sin(i+Position) * 127 + 128)/255)*green,
((sin(i+Position) * 127 + 128)/255)*blue);
}
showStrip();
delay(WaveDelay);
}
}
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 = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
}
}
Error messages
\Arduino\switchInput.main\switchInput.main.ino: In function 'void switchInput(int, int, int)':
\Documents\Arduino\switchInput.main\switchInput.main.ino:33:71: error: a function-definition is not allowed here before '{' token
void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
^
\Documents\Arduino\switchInput.main\switchInput.main.ino:53:22: error: a function-definition is not allowed here before '{' token
void showStrip() {
^
Documents\Arduino\switchInput.main\switchInput.main.ino:64:63: error: a function-definition is not allowed here before '{' token
void setPixel(int Pixel, byte red, byte green, byte blue) {
^
Documents\Arduino\switchInput.main\switchInput.main.ino:77:50: error: a function-definition is not allowed here before '{' token
void setAll(byte red, byte green, byte blue) {
^
exit status 1
Compilation error: a function-definition is not allowed here before '{' token