Browse Source

Add files via upload

master
Hendrik Schutter 5 years ago committed by GitHub
parent
commit
d99e688378
  1. 212
      functions.ino
  2. 85
      nfc01.ino

212
functions.ino

@ -0,0 +1,212 @@
boolean getRC01() {
rc01Val = pulseIn(rc01, HIGH);
//Serial.println(rc01Val);
if (rc01Val > 1500) {
//Serial.println("RC1 ON");
return true;
} else {
//Serial.println("RC1 OFF");
return false;
}
}
boolean getRC02() {
rc02Val = pulseIn(rc02, HIGH);
// Serial.println(rc02Val);
if (rc02Val < 1500) {
pullRC = true;
}
if (rc02Val > 1500 && pullRC) {
//Serial.println("RC2 ON");
pullRC = false;
return true;
} else {
//Serial.println("RC2 OFF");
return false;
}
}
void serialPrintModus(int modus) {
switch (modus) {
case 0:
Serial.println("Black");
break;
case 1:
Serial.println("Red");
break;
case 2:
Serial.println("Blue");
break;
case 3:
Serial.println("Green");
break;
case 4:
Serial.println("White");
break;
case 5:
Serial.println("Rainbow");
break;
case 6:
Serial.println("RainbowWithGlitter");
break;
case 7:
Serial.println("Confetti");
break;
case 8:
Serial.println("Sinelon");
break;
case 9:
Serial.println("BPM");
break;
case 10:
Serial.println("Navigation");
break;
case 11:
Serial.println("Chase");
break;
case 12:
Serial.println("ChaseRGB");
break;
case 13:
Serial.println("Random");
break;
}
}
void rainbow()
{
Serial.println("Rainbow");
// FastLED's built-in rainbow generator
fill_rainbow( leds, NUM_LEDS, gHue, 7);
}
void rainbowWithGlitter()
{
// built-in FastLED rainbow, plus some random sparkly glitter
rainbow();
addGlitter(255);
}
void addGlitter( fract8 chanceOfGlitter)
{
if ( random8() < chanceOfGlitter) {
leds[ random16(NUM_LEDS) ] += CRGB::White;
}
}
void confetti()
{
// random colored speckles that blink in and fade smoothly
fadeToBlackBy( leds, NUM_LEDS, 10);
int pos = random16(NUM_LEDS);
leds[pos] += CHSV( gHue + random8(64), 200, 255);
}
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16(13, 0, NUM_LEDS);
leds[pos] += CHSV( gHue, 255, 192);
}
void bpm()
{
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
uint8_t BeatsPerMinute = 33;
CRGBPalette16 palette = PartyColors_p;
uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
for ( int i = 0; i < NUM_LEDS; i++) { //9948
leds[i] = ColorFromPalette(palette, gHue + (i * 2), beat - gHue + (i * 10));
}
}
void blackMode() {
fill_solid(leds, NUM_LEDS, CRGB::Black); // Just to be sure, let's really make it BLACK.
}
void redMode() {
fill_solid(leds, NUM_LEDS, CRGB::Red);
}
void blueMode() {
fill_solid(leds, NUM_LEDS, CRGB::Blue);
}
void greenMode() {
fill_solid(leds, NUM_LEDS, CRGB::Green);
}
void whiteMode() {
fill_solid(leds, NUM_LEDS, CRGB::White);
}
void navigation() {
FastLED.clear();
leds[0] = CRGB::Red;
leds[1] = CRGB::Red;
leds[2] = CRGB::Red;
leds[41] = CRGB::Green;
leds[42] = CRGB::Green;
leds[43] = CRGB::Green;
leds[5] = CRGB::White;
leds[6] = CRGB::White;
leds[37] = CRGB::White;
leds[38] = CRGB::White;
FastLED.delay(100);
leds[5] = CRGB::Black;
leds[6] = CRGB::Black;
leds[37] = CRGB::Black;
leds[38] = CRGB::Black;
}
void chase() {
FastLED.clear();
// a colored dot sweeping back and forth, with fading trails
//fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16(40, 0, NUM_LEDS);
leds[pos] = CRGB::Red;
if (pos < 41) {
leds[pos + 1] = CRGB::Red;
leds[pos + 2] = CRGB::Red;
}
if (pos > 1) {
leds[pos - 1] = CRGB::Red;
leds[pos - 2] = CRGB::Red;
}
}
void chaseRGB() {
FastLED.clear();
// a colored dot sweeping back and forth, with fading trails
//fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16(40, 0, NUM_LEDS);
leds[pos] += CHSV( gHue, 255, 192);
if (pos < 41) {
leds[pos + 1] += CHSV( gHue, 255, 192);
leds[pos + 2] += CHSV( gHue, 255, 192);
}
if (pos > 1) {
leds[pos - 1] += CHSV( gHue, 255, 192);
leds[pos - 2] += CHSV( gHue, 255, 192);
}
}
void randomMode(){
randomVal = random(0,45);
if(randomVal == 44){
if(random(5,11) == 9){
FastLED.clear();
}
}else{
leds[randomVal] = random(0, 16777216);
}
}

85
nfc01.ino

@ -0,0 +1,85 @@
#include "FastLED.h"
int rc01 = 9;
int rc02 = 10;
int led_spotlight = 2;
int rc01Val = 0;
int rc02Val = 0;
int modus = 0;
int modusMax = 13;
int red = 0;
int green = 0;
int blue = 0;
int randomVal = 0;
#define DATA_PIN 3
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 44
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 255
#define FRAMES_PER_SECOND 60
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
boolean pullRC = true;
void setup() {
//Serial.begin(9600);
Serial.println("_-_-_- Night Fly Controller V01 _-_-_-");
pinMode(rc01, INPUT);
pinMode(rc02, INPUT);
pinMode(led_spotlight, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
delay(3000); // 3 second delay for recovery
// tell FastLED about the LED strip configuration
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
// set master brightness control
FastLED.setBrightness(BRIGHTNESS);
}
// List of patterns to cycle through. Each is defined as a separate function below.
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { blackMode, redMode, blueMode, greenMode, whiteMode, rainbow, rainbowWithGlitter, confetti, sinelon, bpm, navigation, chase, chaseRGB, randomMode };
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
void loop() {
if (getRC01()) {
digitalWrite(led_spotlight, HIGH);
} else {
digitalWrite(led_spotlight, LOW);
}
setModus();
}
void setModus(){
if (getRC02()) {
modus = modus + 1;
if (modus > modusMax) {
modus = 1;
}
}
Serial.println(modus);
serialPrintModus(modus);
gPatterns[modus]();
// send the 'leds' array out to the actual LED strip
FastLED.show();
// insert a delay to keep the framerate modest
FastLED.delay(1000 / FRAMES_PER_SECOND);
// do some periodic updates
EVERY_N_MILLISECONDS( 20 ) {
gHue++; // slowly cycle the "base color" through the rainbow
}
}
Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close