Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Christmas project ....
 
Share:
Notifications
Clear all

[Solved] Christmas project ..

20 Posts
2 Users
0 Reactions
6,285 Views
(@philipking)
Active Member
Joined: 7 years ago
Posts: 9
 

Hi Phil,

Ok Update... It didn't work.

I've gone right back to basics and it STILL doesn't work.... ARRRRGH!!!!! (Hammer time!!!! No... Stop... Think about it... Walk away!)

OK I've got work in under an hour and so I'll sleep on it for now. If you get chance to read (try) the code then feel free. I'll get another chance to revisit it at the weekend 

As for the old Fidonet days (Yep!) I was 2:251/51 (how sad I still remember my Fidonet number!) and NeST (I also has an ST! 1040STFM) but I also linked into AmigaNet (as my brother had(still has)) an Amiga) but cant remember my number on those  .Only had the 1 modem 2400 then 14k4 then 28k8 (all Supra modems) before going to the BIG LEAGUE (after getting a Sysop discount) of a USR-Robotics 56k.

Once I went to being a 24hr BBS then dragging the kit around was impossible (especially with my 5 HDs( think I paid £299 for my first 20meg drive... GOD we're showing our age!)  . But I did enjoy those days. 

Speak to you soon.

Phil


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Hi Phil,

Awesome haha ... well this weekend will be busy for me, as i'm working on one of my projects and have some family things to take care of.

That's interesting, I don't recall our Fidonet number, but the funny part was that we did both as well. Since my buddy was the Atari ST fan and I was the Amiga fan . We did run it on a 1040 as well - my buddy had a "spare" one (advantage of wealthy parents I guess) and I had a couple of modems available. Oh I remember the days indeed. Those US-Robotics modems were kick-ass. I actually got one from the US, when they were not yet available in Europe (my aunt lived in the US at the time).

Yeah we may be showing age, but I refuse to admit to my real age . My first computer was a kit, the Ohio Scientific C1P. A beast to build, but man I learned a lot from that. My nephews (around the age of 14) are into computers as well, but boy are they missing out on what we have played with. They have no clue. They think programming is learned in an afternoon, preferably under 15 minutes. Building a rig is something way over their head (even though it's almost as easy as lego), and their knowledge is limited to games on Steam or their XBox. If they are not playing a game (I'll admit that I still play along with them) it's YouTube. 

Oh well ... I tried getting them onboard with Android, but like I said, it took more than 15 minutes and their attention span didn't make it haha. (that's why I wrote the Arduino C intro).


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  
Next thing I'd try: use a lower serial speed, for example 9600. Speeds like 115,200 can cause issues. Somehow the codes is OK, just yoru serial seems to take a break ... so tat's why I first wa curious about the library and now the speed. See what it does.

I cleaned up your code a little but couldn't find any reason why it would fail (obviously, not sure about how well the effects would work, since I do not even have an Arduino near by). Since I did get confused by some of the loops, I did add a comment at the end of most loops so I knew what they belonged to.

#include "FastLED.h"
#define NUM_LEDS 75 
CRGB leds[NUM_LEDS];
#define PIN 3 
#define Brightness 40
// strip lengths
#define S1 10 //66
#define S2 15 //142
#define S3 15 //71
#define S4 5 //91
#define S5 25 //128
int RunOnce = true ; 
void setup()
{
  FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(Brightness);
  int S2a = S1+S2 ;
  int S3a = S2a+S3 ;
  int S4a = S3a+S4 ;
  Serial.begin(9600);
  Serial.println("Startup running...");
}
void loop() { 
  Serial.println(("Main code running"));
  if (RunOnce == true ){
    RunOnce = false ;
    SolidFill( 255 , 0, 0, 3000, 0, 255, 0 , 3 );
    Serial.println(F("SolidFill Complete...")); 
    Fizzle(0xff, 0xff, 0xff, 300, 1, true);
    Serial.println(("Fizzle Complete..."));
  }
  MeteorRain(0xff,0xff,0xff,2, 200, true, 50);
  Serial.println(("MeteorRain Complete..."));    
}
void SolidFill (int r, int g, int b, int Wait, int r1, int g1, int b1, int Times){
  Serial.println(("Start SolidFill..."));
  for (int x = 0 ; x <= 10 ; x++)
  {
    if (Wait >=2)
     for ( int i = 0 ; i <= Times; i++)
     {
       fill_solid (leds, S1, CRGB( r, g, b));
       fill_solid (leds+S1, S2, CRGB( r1, g1, b1));
       fill_solid (leds+(S1+S2), S3, CRGB( r, g,b));
       fill_solid (leds+(S1+S2+S3), S4, CRGB( r1, g1, b1));
       fill_solid (leds+(S1+S2+S3+S4), NUM_LEDS, CRGB( r, g, b));
       showStrip();
       delay (Wait);
    
       fill_solid (leds, S1, CRGB( r1, g1, b1));
       fill_solid (leds+S1, S2, CRGB( r, g, b));
       fill_solid (leds+(S1+S2), S3, CRGB( r1, g1, b1));
       fill_solid (leds+(S1+S2+S3), S4, CRGB( r, g, b));
       fill_solid (leds+(S1+S2+S3+S4), NUM_LEDS, CRGB( r1, g1, b1));
       showStrip();
      delay (Wait);
     } // for i
    
   if (Wait <=1000) { Wait = Wait/2; }
   else { Wait = Wait - 1000; }
  } // for x
}
void MeteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {  
  Serial.println(("MeteorRain Started..."));
  for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
    for(int j=0; j<NUM_LEDS; j++) {
      if( (!meteorRandomDecay) || (random(10)>5) ) { fadeToBlack(j, meteorTrailDecay ); }
    } // for j
    
    // draw meteor
    for(int j = 0; j < meteorSize; j++) {
      if( ( i-j <NUM_LEDS) && (i-j>=0) ) { setPixel(i-j, red, green, blue); } 
    } // for j
   
    showStrip();
    delay(SpeedDelay);
  } // for i
}
void fadeToBlack(int ledNo, byte fadeValue) {
   leds[ledNo].fadeToBlackBy( fadeValue );
}
void Fizzle(byte red, byte green, byte blue, int Count, int SpeedDelay, boolean OnlyOne) {
  for (int i=0; i<Count; i++) 
  {
     setPixel(random(NUM_LEDS),red,green,blue);
     showStrip();
     delay(SpeedDelay);
     if(OnlyOne) { setAll(0,0,0); }
  } // for i
}
  
void Fuse() {
  for ( int r = 0 ; r <= 10 ; r++)
  {
    FastLED.setBrightness(r);
    fill_solid (leds, NUM_LEDS, CRGB( 155 , 57, 15));
    showStrip();
    delay (200);
  }
  delay (3000);
}
// FastLED main sequences
void showStrip() {
   FastLED.show();
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
   leds[Pixel].r = red;
   leds[Pixel].g = green;
   leds[Pixel].b = blue;
}
void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) { setPixel(i, red, green, blue); }
  showStrip();
}

   
ReplyQuote
(@philipking)
Active Member
Joined: 7 years ago
Posts: 9
 

Morning Hans,

Sorry I've not written anything these last few days, I've just not had the energy to do much due to a heavy cold (I've gone to work then almost immediately gone to bed), 

Yesterday I went right back to basics and rewote the code (albeit for my 75leds) but although not quite what I needed I did get the basic code sorted (and tidied up a bit too), more modification is required and delete the bits of code that I don't really need.

// Testing version, last update (working test_C) (21/9/18)
// this version has short red fuse after rgb sequence
// then runs twinkle and white meteor
// I like this one as it uses if statement to run sequence
#include "FastLED.h"
#define NUM_LEDS 75 
CRGB leds[NUM_LEDS];
#define PIN 3 
#define Brightness 20
// strip lengths (not used for now, but are needed when using the mirror of Fire)
#define S1 10 //66
#define S2 15 //142
#define S3 15 //71
#define S4 5 //91
#define S5 25 //128
int RunOnce = true ; 
void setup()
{
  FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(Brightness);
// variables not used for now (may be removed)
int S2a = S1+S2 ;
int S3a = S2a+S3 ;
int S4a = S3a+S4 ;
}
// REPLACE FROM HERE
void loop() { 
if (RunOnce == true)
 {
  StartUp();
  RunOnce = false;
 }
// TwinkleRandom - twinkle count, speed delay, only one (true/false)
 TwinkleRandom(2000, 1, false);
// meteorRain - Color (red, green, blue), meteor size, trail decay, random trail decay (true/false), speed delay 
   meteorRain(0x00,0xff,0x00,10, 64, true, 30);
   
 }
void StartUp(){
 rgb(2000, 3); // delay time , number of times to flash
 // Twinkle - Color (red, green, blue), count, speed delay, only one twinkle (true/false)
  Twinkle(0xff, 0xff, 0xff, 1000,1, true); // ff,00,00,10,100,false
  // meteorRain - Color (red, green, blue), meteor size, trail decay, random trail decay (true/false), speed delay 
   meteorRain(0xff,0x00,0x00,2, 200, true, 30);
//delay (4000);
}
void rgb(int wait, int t)

 do {
for (int i = 0 ; i <= t; i++){
    fill_solid (leds, NUM_LEDS, CRGB( 255, 0, 0));
      FastLED.show();
        delay (wait);
    fill_solid (leds, NUM_LEDS, CRGB( 0, 255, 0));
       FastLED.show();
         delay (wait);
    fill_solid (leds, NUM_LEDS, CRGB( 0, 0, 255));
      FastLED.show();
        delay (wait);
 
}
  wait =wait/2 ;
}
while (wait >=1);
setAll(0,0,0);
//delay (4000);
}
void Twinkle(byte red, byte green, byte blue, int Count, int SpeedDelay, boolean OnlyOne) {
  // setAll(0,0,0);
  
  for (int i=0; i<Count; i++) {
     setPixel(random(NUM_LEDS),red,green,blue);
     showStrip();
     delay(SpeedDelay);
     if(OnlyOne) { 
       setAll(0,0,0); 
     }
   }
  
  delay(SpeedDelay);
}
void TwinkleRandom(int Count, int SpeedDelay, boolean OnlyOne) {
  setAll(0,0,0);
  
  for (int i=0; i<Count; i++) {
     setPixel(random(NUM_LEDS),random(0,255),random(0,255),random(0,255));
     showStrip();
     delay(SpeedDelay);
     if(OnlyOne) { 
       setAll(0,0,0); 
     }
   }
  
  delay(SpeedDelay);
}
void Sparkle(byte red, byte green, byte blue, int SpeedDelay) {
  int Pixel = random(NUM_LEDS);
  setPixel(Pixel,red,green,blue);
  showStrip();
  delay(SpeedDelay);
  setPixel(Pixel,0,0,0);
}
void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {  
  setAll(0,0,0);
  
  for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
    
    
    // fade brightness all LEDs one step
    for(int j=0; j<NUM_LEDS; j++) {
      if( (!meteorRandomDecay) || (random(10)>5) ) {
        fadeToBlack(j, meteorTrailDecay );        
      }
    }
    
    // draw meteor
    for(int j = 0; j < meteorSize; j++) {
      if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
        setPixel(i-j, red, green, blue);
      } 
    }
   
    showStrip();
    delay(SpeedDelay);
  }
}
// used by meteorrain
void fadeToBlack(int ledNo, byte fadeValue) {
 #ifdef ADAFRUIT_NEOPIXEL_H 
    // NeoPixel
    uint32_t oldColor;
    uint8_t r, g, b;
    int value;
    
    oldColor = strip.getPixelColor(ledNo);
    r = (oldColor & 0x00ff0000UL) >> 16;
    g = (oldColor & 0x0000ff00UL) >> 8;
    b = (oldColor & 0x000000ffUL);
    r=(r<=10)? 0 : (int) r-(r*fadeValue/256);
    g=(g<=10)? 0 : (int) g-(g*fadeValue/256);
    b=(b<=10)? 0 : (int) b-(b*fadeValue/256);
    
    strip.setPixelColor(ledNo, r,g,b);
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   leds[ledNo].fadeToBlackBy( fadeValue );
 #endif  
}
// REPLACE TO HERE


// ***************************************
// ** FastLed/NeoPixel Common Functions **
// ***************************************
// Apply LED color changes
void showStrip() {
 #ifdef ADAFRUIT_NEOPIXEL_H 
   // NeoPixel
   strip.show();
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   FastLED.show();
 #endif
}
// Set a LED color (not yet visible)
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
}
// Set all LEDs to a given color and apply it (visible)
void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, green, blue); 
  }
  showStrip();
}

I've also had a play with the meteorRain sequence. I changed the parameters it gets sent so that it does it in house. As you can see it changes the RGB codes to random, the result it a random colour every time it runs the code. Kids think its brilliant 

byte red    = random8(255); //0xff;
byte green = random8(255); //0xff;
byte blue = random8(255); //0xff;
byte meteorSize = 10;
byte meteorTrailDecay = 64;
boolean meteorRandomDecay = true;
int SpeedDelay = 30;

Now to add the fire routine and upload it to the 500 leds... Maybe next week (when most of the neighbors are working so they cant see it)  

Enjoy your weekend.

Phil


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Sorry for the late reply Phil! 

I'm not always that fast in replying, and when I don't reply right away, the email notification slips lower on the list, which I sometimes overlook hahah.

Anyhoo; curious at the end-result - pleasing the kids is important 


   
ReplyQuote
Page 2 / 2
Share: