TimerOne.h LED Effekt
-
Hello,
I am an Arduino beginner and have tried to do it by myself. Unfortunately it does not work.
I would like my Demo LED effect to turn on after 3 minutes, but it does not turn on. Therefore I am looking for some help. Could anybody please help me and say where the error is in my sketch.#include <Adafruit_NeoPixel.h> #include <TimerOne.h> #define PINR 6 int led_ring = 60; // Leds (Ring) Adafruit_NeoPixel ring = Adafruit_NeoPixel(led_ring, PINR, NEO_GRB + NEO_KHZ800); boolean Demo = false; int command = 0 ; uint32_t c; int all_x_minut=3; // void setup() { ring.begin(); ring.show(); ring.setBrightness(75); Serial.begin(9600); Timer1.initialize(all_x_minut*60000); Timer1.attachInterrupt(Demostart); } // ************** Programm ******************** void loop() { if (Serial.available() > 0) { Timer1.initialize(all_x_minut*60000); Demo == true; command = Serial.read(); { } } if (Demo == true) { Demomodus(); } } // *************** Funktionen ******************** void rainbowCycle(uint8_t wait) { uint16_t i, j; for(j=0; j<256*1; j++) { // 5 cycles of all colors on wheel for(i=0; i< ring.numPixels(); i++) { ring.setPixelColor(i, Wheel(((i * 256 / ring.numPixels()) + j) & 255)); } ring.show(); delay(wait); } } uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return ring.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return ring.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return ring.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } void Demomodus() { rainbowCycle(55); } void Demostart() { Demo == true; }Thank you in advance and kind regards!
-
Hello,
I am an Arduino beginner and have tried to do it by myself. Unfortunately it does not work.
I would like my Demo LED effect to turn on after 3 minutes, but it does not turn on. Therefore I am looking for some help. Could anybody please help me and say where the error is in my sketch.#include <Adafruit_NeoPixel.h> #include <TimerOne.h> #define PINR 6 int led_ring = 60; // Leds (Ring) Adafruit_NeoPixel ring = Adafruit_NeoPixel(led_ring, PINR, NEO_GRB + NEO_KHZ800); boolean Demo = false; int command = 0 ; uint32_t c; int all_x_minut=3; // void setup() { ring.begin(); ring.show(); ring.setBrightness(75); Serial.begin(9600); Timer1.initialize(all_x_minut*60000); Timer1.attachInterrupt(Demostart); } // ************** Programm ******************** void loop() { if (Serial.available() > 0) { Timer1.initialize(all_x_minut*60000); Demo == true; command = Serial.read(); { } } if (Demo == true) { Demomodus(); } } // *************** Funktionen ******************** void rainbowCycle(uint8_t wait) { uint16_t i, j; for(j=0; j<256*1; j++) { // 5 cycles of all colors on wheel for(i=0; i< ring.numPixels(); i++) { ring.setPixelColor(i, Wheel(((i * 256 / ring.numPixels()) + j) & 255)); } ring.show(); delay(wait); } } uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return ring.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return ring.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return ring.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } void Demomodus() { rainbowCycle(55); } void Demostart() { Demo == true; }Thank you in advance and kind regards!
Welcome to the MySensors community @xsav
The easiest way would probably be to remove everything related to TimerOne and replace with this:void loop(){ wait(3*60*1000); Demomodus(); }If you want to use TimerOne you need to enter the number of microseconds to sleep, not milliseconds.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login