Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. TimerOne.h LED Effekt

TimerOne.h LED Effekt

Scheduled Pinned Locked Moved Troubleshooting
2 Posts 2 Posters 972 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xsav
    wrote on last edited by
    #1

    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!

    mfalkviddM 1 Reply Last reply
    0
    • X xsav

      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!

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #2

      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.

      1 Reply Last reply
      0

      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
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      14

      Online

      12.1k

      Users

      11.2k

      Topics

      113.4k

      Posts


      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • MySensors
      • OpenHardware.io
      • Categories
      • Recent
      • Tags
      • Popular