#4881546
Hello

Ones again thank you for all your codes.
I have a little question about this one.
It works fine, but I have a little problem.
At start you have " Who ya gonna call? Ghostbusters!" scrolling one the 6 digit display, and this is really great.
After that you have a loop and the values goes from 12999 through 12000.
But when the loop start again automatically, the text " Who ya gonna call? Ghostbusters!"scrolling again.
Is it possible to have the text just at start and only have numbers in the loop ?
I've try many things but it never works.

Thank you for your futur answers.
tommyb345 wrote:and heres my latest sketch for my displays
this starts up with a scrolling display message on the top display and then proceeds to the randomizing displays
nice looking 3d printed parts by the way hehe

#include <GhostLab42Reboot.h>
#include <Wire.h>

GhostLab42Reboot reboot;

void setup()
{
reboot.begin();
reboot.write(1, "126.2");
reboot.write(2, "-42.9");

// Turn down the brightness of the main displays
reboot.setDisplayBrightness(0, 60);
reboot.setDisplayBrightness(1, 100);
reboot.setDisplayBrightness(2, 60);
}

void loop()
{
// String to be scrolled across the six digit display
// Need the extra spaces to make the scrolling smooth
String displayText = " Who ya gonna call? Ghostbusters! ";

// A NOTE ABOUT SCROLLING:
// This works fine if there are not any periods/decimals, since a period/decimal
// is either considered part of the previous character or its own character if
// it is in the first position of the display (in which case there is technically
// a "space" in front of it)
// Check out ex4_scrollingtextadvanced instead if you are planning on scrolling a
// string with a period/decimal

// Commence scrolling
for (int i = 0; i < displayText.length(); i++)
{
reboot.write(0, displayText.substring(i, i + 6));
delay(250);
}

// Clear and start over
reboot.resetDisplay(0);

String countStr;
int count = 2087;

for (int i = 0; i < 1000; i++)
{
// Count down
reboot.write(0, String(120999 - i));

// Count up with leading 0s really fast
countStr = "000" + String(16 * i);
reboot.write(1, countStr.substring(countStr.length() - 4));

// Show a number that is about 2087 but moves around randomly by a few counts
// Slow the update down so it changes more slowly
if ((i % 30) == 0)
{
count = 2087 + random(-2, 3);
}

reboot.write(2, String(count));

delay(30);
}}
#4881583
Thanks so much for all the help!
I have it mostly completed with a couple of pieces here and there.
After all the work I am pleased.
Though some thinks like the gun I wish was a little better and I wish I had that awesome startup sound that a couple of people have used on theirs.

https://youtu.be/wA1-qJ4t16E

[Youtube]https://youtu.be/wA1-qJ4t16E[/Youtube]

Image

Image
#4881629
tataioioioio wrote: But when the loop start again automatically, the text " Who ya gonna call? Ghostbusters!"scrolling again.
Is it possible to have the text just at start and only have numbers in the loop ?
If I am understanding correctly, try this code:

Code: Select all
#include <GhostLab42Reboot.h>
#include <Wire.h>

GhostLab42Reboot reboot;

void setup()
{
	reboot.begin();
	reboot.write(1, "126.2");
	reboot.write(2, "-42.9");

	// Turn down the brightness of the main displays
	reboot.setDisplayBrightness(0, 60);
	reboot.setDisplayBrightness(1, 100);
	reboot.setDisplayBrightness(2, 60);

	// String to be scrolled across the six digit display
	// Need the extra spaces to make the scrolling smooth
	String displayText = "      Who ya gonna call?     Ghostbusters!      ";

	// A NOTE ABOUT SCROLLING:
	// This works fine if there are not any periods/decimals, since a period/decimal
	// is either considered part of the previous character or its own character if
	// it is in the first position of the display (in which case there is technically
	// a "space" in front of it)
	// Check out ex4_scrollingtextadvanced instead if you are planning on scrolling a
	// string with a period/decimal

	// Commence scrolling
	for (int i = 0; i < displayText.length(); i++)
	{
		reboot.write(0, displayText.substring(i, i + 6));
		delay(250);
	}

	// Clear and start over
	reboot.resetDisplay(0);
}

void loop()
{


	String countStr;
	int count = 2087;

	for (int i = 0; i < 1000; i++)
	{
		// Count down
		reboot.write(0, String(120999 - i));

		// Count up with leading 0s really fast
		countStr = "000" + String(16 * i);
		reboot.write(1, countStr.substring(countStr.length() - 4));

		// Show a number that is about 2087 but moves around randomly by a few counts
		// Slow the update down so it changes more slowly
		if ((i % 30) == 0)
		{
			count = 2087 + random(-2, 3);
		}

		reboot.write(2, String(count));

		delay(30);
	}
}
I moved the Who You Gonna Call text up into the setup part of the code, as it only runs once, on start up.

I don't have my 6 digit displays hooked up yet, so please let me know if this doesn't work. I was not able to test it.
tataioioioio liked this
#4881718
OOOHHHHH MightyAni GOOODDD of Codes hear my pray !

I wanted to know if it's possible to make this effect on an adafruit neopixel 60

https://www.youtube.com/watch?v=OR33T0X-W7k

the code is this one:

/*
Reboot Ghostbusters Proton Pack (lights only)
NeoPixel Driver for Trinket Pro

Authors: Dustin Westaby, Danielle Gormley
Date: August 31, 2016

Use a 24 LED neopixel ring, or loop a strip.
Animation is to match the Proton Pack from 2016 movie

Use potentiometer for a color selection knob.

*/

#include <Adafruit_NeoPixel.h>

//neopixel strip config
#define NEO_PIN 6
#define NUM_LEDS 24

//color selection knob config
#define POT_PIN A0
#define ENABLE_COLOR_KNOB 1 //Set to 0 if you do not plan to use a potentiometer for color selection
#define USER_COLOR 0xff0000 //default color, red

//animation options (larger speed = slower)
#define SLOW_SWEEP_SPEED 100
#define SPIN_UP_SPEED 50
#define MIN_SPIN_UP_SPINS 5 //will spin random number of times, at least this many
#define MAX_SPIN_UP_SPINS 15 //will spin random number of times, up to this many
#define FADE_SPEED 20
#define FADE_DURATION_CHANCE 5 //good chance of escaping loop
#define MOVIE_SPIN_SPEED 50
#define MOVIE_SPIN_PERCENTAGE 0.74 //this is the percentage of the ring that is ON during the chase animation
#define MOVIE_SPIN_DURATION_CHANCE 30 //small chance that startup animation will repeat

//initialization
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, NEO_PIN, NEO_GRB + NEO_KHZ800);
uint32_t colorselected = USER_COLOR;

void setup()
{

// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code

strip.begin();
strip.show(); // Initialize all pixels to 'off'

randomSeed(analogRead(A1)); //read unused pin

//get user selected color color on startup
update_color_and_delay(0);
}


//animation loop
void loop()
{
//slow sweep
colorWipe(SLOW_SWEEP_SPEED);

//spin up, faster and faster
RunningLights(random(MIN_SPIN_UP_SPINS, MAX_SPIN_UP_SPINS), SPIN_UP_SPEED);

//fade for a while
while(random(0, FADE_DURATION_CHANCE))
{
FadeOut(FADE_SPEED);
FadeIn(FADE_SPEED / 4);
}
FadeOut(FADE_SPEED);

//classic movie spin
while(random(0, MOVIE_SPIN_DURATION_CHANCE))
{
three_quadrant_spin(MOVIE_SPIN_SPEED);
}

//get ready for starup animations to repeat
FadeOut(FADE_SPEED / 2);
setAll(0, 0, 0);
}

void update_color_and_delay(uint16_t wait)
{
int analog = 0;
uint32_t colorwheel[] =
{
0xff0000, //0 red
0x800000, //1 maroon
0xff4000, //2 orange
0xffff00, //3 yellow
0x808000, //4 olive
0x800080, //5 purple
0xff00ff, //6 fuschia
0xffffff, //7 white
0x000080, //8 navy
0x0000ff, //9 blue
0x00ffff, //10 aqua
0x008080, //11 teal
0x00ff00, //12 lime
0x008000, //13 green
};

if(ENABLE_COLOR_KNOB)
{
//read potentiometer and use a map lookup to update global color
analog = analogRead(POT_PIN);
colorselected = colorwheel[map(analog, 0, 1024, 0, ( sizeof( colorwheel ) / sizeof( uint32_t ) ) )];
}

delay(wait);
}

void three_quadrant_spin(uint8_t wait)
{
float on_percentage = MOVIE_SPIN_PERCENTAGE;
float off_percentage = 1 - on_percentage;

//start with percent on
for(int i = 0; i < NUM_LEDS; i++ )
{
if(i < (NUM_LEDS * on_percentage))
{
strip.setPixelColor(i, colorselected);
}
else
{
strip.setPixelColor(i, 0);
}
}
strip.show();
delay(1);

//animate 2 pixels at a time (chasers)
for (int i = 0; i < strip.numPixels(); i++)
{
//handle max pixel to pixel 0 transition
if( ( i + (NUM_LEDS * on_percentage) ) < NUM_LEDS )
{
strip.setPixelColor(i, 0);
strip.setPixelColor(i + (NUM_LEDS * on_percentage), colorselected);
}
else
{
strip.setPixelColor(i, 0);
strip.setPixelColor(i - (NUM_LEDS * off_percentage), colorselected);
}

strip.show();
update_color_and_delay(wait);
}
}


byte getRed(uint32_t c)
{
return (c >> 16) & 0xFF;
}
byte getGreen(uint32_t c)
{
return (c >> 8) & 0xFF;
}
byte getBlue(uint32_t c)
{
return (c) & 0xFF;
}

void FadeIn(uint8_t wait)
{
float r, g, b;

for(int k = 0; k < 256; k = k + 1)
{
r = (k / 256.0) * getRed(colorselected);
g = (k / 256.0) * getGreen(colorselected);
b = (k / 256.0) * getBlue(colorselected);
setAll(r, g, b);
strip.show();
update_color_and_delay(wait);
}
}

void FadeOut(uint8_t wait)
{
float r, g, b;

for(int k = 255; k >= 0; k = k - 2)
{
r = (k / 256.0) * getRed(colorselected);
g = (k / 256.0) * getGreen(colorselected);
b = (k / 256.0) * getBlue(colorselected);
setAll(r, g, b);
strip.show();
update_color_and_delay(wait);
}
}

// Fill the dots one after the other with a color
void colorWipe(uint8_t wait)
{
for(uint16_t i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, colorselected);
strip.show();
update_color_and_delay(wait);
}
}

// Nifty pulsing spinning animation
void RunningLights(uint8_t spins, int WaveDelay)
{
int Position = 0;

for(int j = 0; j < NUM_LEDS * spins; j++) //number of spins
{
Position--;
for(int i = 0; i < NUM_LEDS; i++)
{
strip.setPixelColor(i,
strip.Color( ((sin(i + Position) * 127 + 128) / 255)*getRed(colorselected),
((sin(i + Position) * 127 + 128) / 255)*getGreen(colorselected),
((sin(i + Position) * 127 + 128) / 255)*getBlue(colorselected)) );
}

strip.show();

//speed up the animation with each succession
update_color_and_delay(WaveDelay - map(j, 0, NUM_LEDS * spins, 0, WaveDelay + 1));

/* example delay math: 24 LEDs * 10 spins, with 50 Delay

loop map delay
0 0 50 (slowest)
40 8 42
80 17 33
120 25 25
160 34 16
200 42 8
239 50 0 (fastest)

*/
}

}

void setAll(byte red, byte green, byte blue)
{
for(int i = 0; i < NUM_LEDS; i++ )
{
strip.setPixelColor(i, strip.Color(red, green, blue));
}
strip.show();
}

and if it's possible to when i push a button to have the same flash as you.

I am really sorry to ask sooo much things but I am completely lost ! For exemple I don't know why "colors" seems to be defined differently. In a code , you have 3 values for a color (mix of R,G,B = the color than you want) and in other codes red is define by a code like "0xff0000". It's disturbing for beginners

Thank you
#4881853
tataioioioio wrote:I am really sorry to ask sooo much things but I am completely lost ! For exemple I don't know why "colors" seems to be defined differently. In a code , you have 3 values for a color (mix of R,G,B = the color than you want) and in other codes red is define by a code like "0xff0000". It's disturbing for beginners
No, please do not be afraid to ask for help. There is a definite learning curve to this stuff, and I am really only a beginner myself. I've had a lot of help, and I want to pay it forward.

The colors of the Neopixels are sent out to the strip in bits. The "0xff0000" you see is just the hexidecimal representation of the color this programmer wants to see on his strip. In hexidecimal, "0" is the lowest value and "F" is the highest value. Hex goes 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Hexidecimal is base-16, whereas you and I are used to numbers' being base-10.

So, in his color list in the code where he has red, maroon, yellow, etc., he's just pushing those bit instructions out to the NeoPixels. For red, we'd want to turn the "red" part of the NeoPixel on, but have the green and blue parts off, hence "FF" for red, "00" for green, and "00" for blue in ff0000. And so on for the other colors.

I prefer r, g, b values, but as I said, I'm still a beginner, and it's easier for me to think in terms of 0 to 255 than it is for me to think in terms of hexidecimal values.
and if it's possible to when i push a button to have the same flash as you.
EDIT:

Ok, here's a version of the code that (mostly) works and will serve if I don't get a chance to look at it before Halloween:
Code: Select all
/*
Reboot Ghostbusters Proton Pack (lights only)
NeoPixel Driver for Trinket Pro

Authors: Dustin Westaby, Danielle Gormley
Date: August 31, 2016

Use a 24 LED neopixel ring, or loop a strip.  (Mostly working for 60 NeoPixels)
Animation is to match the Proton Pack from 2016 movie

Use potentiometer for a color selection knob.

*/

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
	#include <avr/power.h>
#endif

//neopixel strip config
#define NEO_PIN   6
#define NUM_LEDS  60

//color selection knob config
#define POT_PIN             A0
#define ENABLE_COLOR_KNOB   1       //Set to 0 if you do not plan to use a potentiometer for color selection
#define USER_COLOR      0xff0000 //default color, red

//animation options (larger speed = slower)
#define SLOW_SWEEP_SPEED            100
#define SPIN_UP_SPEED               50
#define MIN_SPIN_UP_SPINS            5    //will spin random number of times, at least this many
#define MAX_SPIN_UP_SPINS           15    //will spin random number of times, up to this many
#define FADE_SPEED                  20
#define FADE_DURATION_CHANCE        5     //good chance of escaping loop
#define MOVIE_SPIN_SPEED            50
#define MOVIE_SPIN_PERCENTAGE       0.74  //this is the percentage of the ring that is ON during the chase animation
#define MOVIE_SPIN_DURATION_CHANCE  30    //small chance that startup animation will repeat

//initialization
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, NEO_PIN, NEO_GRB + NEO_KHZ800);
uint32_t colorselected = USER_COLOR;

const byte buttonPin = 2;      //The input pin is where the pushbutton switch is located

int val;               //This variable stores the state of the input pin
int buttonState = 0;      //Store the state of the switch
int flashMode = 0;         //0 means the LEDs are doing the regular animation...
					  //...and 1 means the LEDs are flashing hues of blue and white

int delayval;            //How quick will blue and white flash?
int rd, gn, bl;
int low = 0;            //The bottom of the color range
int range = 255;         //The spread of the color range
int delayshort = 20;      //Fast flashing, 20 ms delay
int delaylong = 50;         //Slower flashing, 50 ms delay


void setup()
{

	// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
	if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
	// End of trinket special code

	pinMode(buttonPin, INPUT);	//Tell the Arduino the pushbutton is an input
	Serial.begin(9600);			//open the serial port at 9600 baud
	
	strip.begin();
	strip.show(); // Initialize all pixels to 'off'

	buttonState = digitalRead(buttonPin);	//Read the inital state of the pushbutton

	attachInterrupt(digitalPinToInterrupt(buttonPin), BlueWhiteFlashing, LOW);
	
	randomSeed(analogRead(A1)); //read unused pin
	
	update_color_and_delay(0);	//get user selected color color on startup
}


//animation loop
void Animotion() {
	
	//slow sweep
	colorWipe(SLOW_SWEEP_SPEED);

	//spin up, faster and faster
	RunningLights(random(MIN_SPIN_UP_SPINS, MAX_SPIN_UP_SPINS), SPIN_UP_SPEED);

	//fade for a while
	while (random(0, FADE_DURATION_CHANCE))
	{
		FadeOut(FADE_SPEED);
		FadeIn(FADE_SPEED / 4);
	}
	FadeOut(FADE_SPEED);

	//classic movie spin
	while (random(0, MOVIE_SPIN_DURATION_CHANCE))
	{
		three_quadrant_spin(MOVIE_SPIN_SPEED);
	}

	//get ready for starup animations to repeat
	FadeOut(FADE_SPEED / 2);
	setAll(0, 0, 0);

}


void update_color_and_delay(uint16_t wait)
{
	int analog = 0;
	uint32_t colorwheel[] =
	{
		0xff0000, //0 red
		0x800000, //1 maroon
		0xff4000, //2 orange
		0xffff00, //3 yellow
		0x808000, //4 olive
		0x800080, //5 purple
		0xff00ff, //6 fuschia
		0xffffff, //7 white
		0x000080, //8 navy
		0x0000ff, //9 blue
		0x00ffff, //10 aqua
		0x008080, //11 teal
		0x00ff00, //12 lime
		0x008000, //13 green
	};

	if (ENABLE_COLOR_KNOB)
	{
		//read potentiometer and use a map lookup to update global color
		analog = analogRead(POT_PIN);
		colorselected = colorwheel[map(analog, 0, 1024, 0, (sizeof(colorwheel) / sizeof(uint32_t)))];
	}

	delay(wait);
}

void three_quadrant_spin(uint8_t wait)
{
	float on_percentage = MOVIE_SPIN_PERCENTAGE;
	float off_percentage = 1 - on_percentage;

	//start with percent on
	for (int i = 0; i < NUM_LEDS; i++)
	{
		if (i < (NUM_LEDS * on_percentage))
		{
			strip.setPixelColor(i, colorselected);
		}
		else
		{
			strip.setPixelColor(i, 0);
		}
	}
	strip.show();
	delay(1);

	//animate 2 pixels at a time (chasers)
	for (int i = 0; i < strip.numPixels(); i++)
	{
		//handle max pixel to pixel 0 transition
		if ((i + (NUM_LEDS * on_percentage)) < NUM_LEDS)
		{
			strip.setPixelColor(i, 0);
			strip.setPixelColor(i + (NUM_LEDS * on_percentage), colorselected);
		}
		else
		{
			strip.setPixelColor(i, 0);
			strip.setPixelColor(i - (NUM_LEDS * off_percentage), colorselected);
		}

		strip.show();
		update_color_and_delay(wait);
	}
}


byte getRed(uint32_t c)
{
	return (c >> 16) & 0xFF;
}
byte getGreen(uint32_t c)
{
	return (c >> 8) & 0xFF;
}
byte getBlue(uint32_t c)
{
	return (c)& 0xFF;
}

void FadeIn(uint8_t wait)
{
	float r, g, b;

	for (int k = 0; k < 256; k = k + 1)
	{
		r = (k / 256.0) * getRed(colorselected);
		g = (k / 256.0) * getGreen(colorselected);
		b = (k / 256.0) * getBlue(colorselected);
		setAll(r, g, b);
		strip.show();
		update_color_and_delay(wait);
	}
}

void FadeOut(uint8_t wait)
{
	float r, g, b;

	for (int k = 255; k >= 0; k = k - 2)
	{
		r = (k / 256.0) * getRed(colorselected);
		g = (k / 256.0) * getGreen(colorselected);
		b = (k / 256.0) * getBlue(colorselected);
		setAll(r, g, b);
		strip.show();
		update_color_and_delay(wait);
	}
}

// Fill the dots one after the other with a color
void colorWipe(uint8_t wait)
{
	for (uint16_t i = 0; i < strip.numPixels(); i++)
	{
		strip.setPixelColor(i, colorselected);
		strip.show();
		update_color_and_delay(wait);
	}
}

// Nifty pulsing spinning animation
void RunningLights(uint8_t spins, int WaveDelay)
{
	int Position = 0;

	for (int j = 0; j < NUM_LEDS * spins; j++) //number of spins
	{
		Position--;
		for (int i = 0; i < NUM_LEDS; i++)
		{
			strip.setPixelColor(i,
				strip.Color(((sin(i + Position) * 127 + 128) / 255)*getRed(colorselected),
					((sin(i + Position) * 127 + 128) / 255)*getGreen(colorselected),
					((sin(i + Position) * 127 + 128) / 255)*getBlue(colorselected)));
		}

		strip.show();

		//speed up the animation with each succession
		update_color_and_delay(WaveDelay - map(j, 0, NUM_LEDS * spins, 0, WaveDelay + 1));

		/* example delay math: 24 LEDs * 10 spins, with 50 Delay

		loop  map   delay
		0    0    50 (slowest)
		40     8    42
		80    17    33
		120   25    25
		160   34    16
		200   42     8
		239   50     0 (fastest)

		*/
	}

}

void setAll(byte red, byte green, byte blue)
{
	for (int i = 0; i < NUM_LEDS; i++)
	{
		strip.setPixelColor(i, strip.Color(red, green, blue));
	}
	strip.show();
}

void BlueWhiteFlashing() {	//Gets called when the Interrupt Service Routine (ISR) is activated
	
	//Randomly choose the color the NeoPixels will have while the pushbutton switch is pressed
	//Take that color and apply it to all NeoPixels
	rd = low + random(0, 75);      //The red channel.  Brightness goes between 0 (off) and its
							 //contribution to white, 100.
	gn = rd;                  //The green channel, same as red
	bl = random(25, 150);         //The blue channel.  Want to have a lot of blues.

						    //For a set of NeoPixels the first NeoPixel is 0, the second is 1, all the way up to
						    //the count of NeoPixels, minus one.
	for (int i = 0; i < NUM_LEDS; i++) {
		//RGB values from a minimum of (0, 0, 0) up to a maximum of (255, 255, 255)
		strip.setPixelColor(i, strip.Color(rd, gn, bl));   //Pulse the NeoPixels, hues of blue
	}
	strip.show();      //Send the updated pixel color out to the NeoPixel ring

	delayval = random(delayshort, delaylong);
	//delay(delayval);   //Delay for a period of time before the next flash, in milliseconds
	delayMicroseconds(delayval);
}


void loop() {
	Animotion();
}
There must be a potentiometer hooked up to Analog pin 0, A0, for this code to execute properly. Additionally, I tested this on one of my Unos, whereas I noticed the originator ran it off a Pro Trinket, so please let me know if your device gets borked.

I had to learn about interrupts to write this, otherwise it would have taken me a very long time to keep track of state variables inside the Animotion() function. Because of the way interrupts work--for example, delay() does not work inside interrupts--the BlueWhiteFlashing function does not blue-white-flash like it does when I used tommyb's red comet code.

I'm sure I could eventually get it working correctly, but I kinda want to go into the shop and bend some metal, so I'm done for now. :]

Good luck!
#4882012
@MightyAni

I've tried your code and the start is amazing. after I don't know why but the push button seems not work.
I think it could be the hardware because if I connect juste a cable in pin 2 I have a white flash and everything stop. I don't know why. I've try to change the code tu use pin 13. The loop start but the button didn't' work. If you have an idea ?
I will try few things and if I find the problem I will tel you. Thanks again for your precious help.

We're bringing you the latest updates to the GBFan[…]

The amount of people participating in the milest[…]

This is awesome, One time. I love reading explanat[…]

And, lastly, for now, the video that prompted me t[…]