0

XRAD'S FLAMETHROWER
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

XRAD'S FLAMETHROWER

by XRAD on Sat Nov 10, 2018 5:57 pm

Maxed out trinket at 98%. Using a significantly modified code for Neopix flame effect and a few other cool items to make a pocket sized flamethrower! This is the test version to see if it is even feasible . It is. Ordered a few 3w Pixies...more to come...
Attachments
IMG_2776.JPG
IMG_2776.JPG (95.46 KiB) Viewed 336 times

XRAD
 
Posts: 209
Joined: Sat Nov 19, 2016 3:28 pm

Re: XRAD'S FLAMETHROWER

by XRAD on Sun Nov 11, 2018 10:15 pm

so I did a bit of coding this weekend. I used several basic strategies:

1) fastLED
2) Millis timer
3) buttonPolling
4) all going into a Trinket MO

The goal is to get through 4 really cool neopixel cases without delay. Each neopixel case is easily adjusted for what I want (which is a multi phase strip and at same time single pixel glowing with random brightness, hue, and complete fade to black ). Switch polling worked great to go to next case. But, if I held the button closed, I would fly through all 4 cases round and round. So I added a millis timer. It is easy to add, but you have to think backwards. Now, I can't re-trigger the button for 1500ms, which is perfect. Waiting on a few parts from around the world to build up the futuristic alien toaster.....including a 30mm brushless turbofan. This should be a great addition to my laser blaster version IV. I did have to move out of my old trusty ATtiny85 for a ATSAMD21E18 on the new Trinket MO.

Code: Select all | TOGGLE FULL SIZE
#include <FastLED.h>
#define PIN            2
#define NUMPIXELS      3
#define DELAYVAL       50
#define button 6

uint32_t now = 0;
uint8_t  mode = 0;
CRGB leds[NUMPIXELS];

unsigned long reloadTime = 1500;
unsigned long startMillis;
unsigned long currentMillis;

int buttonPoll = 0;
int state = 0;

void redFire(uint32_t now, CRGB* leds, int numpixels) {
  CRGB red(255, 0, 0);
  CRGB orange( 255, 100, 0);
  for (int i = 0; i < NUMPIXELS; i++) {
    CRGB dest = blend(  red, orange, inoise8((now) * 17, i * 60));
    leds[i] = dest;
  }
  fadeToBlackBy(leds, NUMPIXELS, map(inoise8(now * 50), 0, 200, 200, 20));
}

void blueFire(uint32_t now, CRGB* leds, int numpixels) {
  CRGB blue(0, 0, 255);
  CRGB lightBlue( 0, 255, 255);
  for (int i = 0; i < NUMPIXELS; i++) {
    CRGB dest = blend(  blue, lightBlue, inoise8((now) * 17, i * 60));
    leds[i] = dest;
  }
  fadeToBlackBy(leds, NUMPIXELS, map(inoise8(now * 50), 0, 200, 200, 20));
}

void greenFire(uint32_t now, CRGB* leds, int numpixels) {
  CRGB green(0, 150, 0);
  CRGB lightGreen( 153, 250, 51);
  for (int i = 0; i < NUMPIXELS; i++) {
    CRGB dest = blend(  green, lightGreen, inoise8((now) * 17, i * 60));
    leds[i] = dest;
  }
  fadeToBlackBy(leds, NUMPIXELS, map(inoise8(now * 50), 0, 200, 200, 20));
}


void sparkleFire() {
  for (int i = 0; i <= 1; i++) {
    leds[random(3)] = CRGB::White;
    leds[random(3)] = CRGB::Blue;
    leds[random(3)] = CRGB::Black;
    leds[random(3)] = CRGB::Green;
    leds[random(3)] = CRGB::Yellow;
    leds[random(3)] = CRGB::Red;

    FastLED.setBrightness(175);
    FastLED.show();
    delay(8);
  }
}


void setup() {

  startMillis = millis();

  Serial.begin(115200);
  FastLED.addLeds<NEOPIXEL, PIN>(leds, NUMPIXELS);
  pinMode(PIN, OUTPUT);
  pinMode(button, INPUT_PULLDOWN);
}

void loop() {

  currentMillis = millis();


  if (state >= 4) {
    state = 0;
  }
 
    buttonPoll = digitalRead(button);
   
    if (currentMillis - startMillis < reloadTime) {
     Serial.println("no button press");
      buttonPoll = 0;
    }
   
    else  if (buttonPoll == 1) {
      delay(50);
      buttonPoll = digitalRead(button);
      if (buttonPoll == 1) {
        state = (state + 1);
        startMillis = currentMillis;
        Serial.print("button press  "); Serial.println(state);
      }
    }
 


switch (state) {

case 1:
  blueFire(now, leds, NUMPIXELS);
  FastLED.show();
  Serial.println("case 1");
  delay(DELAYVAL);
  now++;
  break;


case 2:
  greenFire(now, leds, NUMPIXELS);
  FastLED.show();
  Serial.println("case 2");
  delay(DELAYVAL);
  now++;
  break;


case 3:
  sparkleFire();
  Serial.println("case 3");
  break;


default:
  redFire(now, leds, NUMPIXELS);
  FastLED.show();
  Serial.println("default");
  delay(DELAYVAL);
  now++;
  break;
}
}
Last edited by XRAD on Mon Nov 12, 2018 8:07 am, edited 2 times in total.

XRAD
 
Posts: 209
Joined: Sat Nov 19, 2016 3:28 pm

Re: XRAD'S FLAMETHROWER

by adafruit_support_mike on Mon Nov 12, 2018 1:48 am

What are you using to get the haze effect in the photo above?

adafruit_support_mike
 
Posts: 55848
Joined: Thu Feb 11, 2010 2:51 pm

Re: XRAD'S FLAMETHROWER

by XRAD on Mon Nov 12, 2018 8:13 am


XRAD
 
Posts: 209
Joined: Sat Nov 19, 2016 3:28 pm

Re: XRAD'S FLAMETHROWER

by XRAD on Mon Nov 12, 2018 10:07 pm

I have coded a way to poll two buttons, each for scrolling through a few cases, with a relatively simple code, building on the above code. As always, there is another way of doing this, but this works well. One for Servo action and one for neopixel action (I actually just need the 1500-1900 PWM output to do something else, but easy to see a servo move). Using a single millis timer shared by both buttons (so one button press will limit the other and themselves before being able to trigger again, but it's only .5 sec so no one notices). You can easily adjust through the cases for LED or Servo, and both wind up back where they started.

There is an array for the buttonPins, or you could #define each one, or const byte[]...etc.. And in the setup, the buttonPins are all set to PULLDOWN, or you could pinMode each button, etc.... But there is plenty of memory on the Trinket MO... I will switch the pins to Trinket correct pin numbers for PWM, etc..once I get off my test board....

A few more easy power-up button triggers to go, and of course some cool sounds... and pics/video...

Too many carambola packages on my doorstep!!


Code: Select all | TOGGLE FULL SIZE
#include <Servo.h>
#include <FastLED.h>
#define PIN            2    // Neopixel pin
#define NUMPIXELS      3
#define DELAYVAL       50

CRGB leds[NUMPIXELS];
Servo myservo;

unsigned long buttonTimer = 500; // could set it where you like
unsigned long startMillis;
unsigned long currentMillis;
uint32_t now = 0;
uint8_t  mode = 0;

int buttonPollServo = 0;
int buttonPollLED = 0;
int stateServo = 0;
int stateLED = 0;
int pos = 100;
int buttonPins[] = {10, 11, 12}; //button array for pins: 10 = servo , 11 = unused, 12 = Pixels

void redFire(uint32_t now, CRGB* leds, int numpixels) {
  CRGB red(255, 0, 0);
  CRGB orange( 255, 100, 0);
  for (int i = 0; i < NUMPIXELS; i++) {
    CRGB dest = blend(  red, orange, inoise8((now) * 17, i * 60));
    leds[i] = dest;
  }
  fadeToBlackBy(leds, NUMPIXELS, map(inoise8(now * 50), 0, 200, 200, 20));
}

void blueFire(uint32_t now, CRGB* leds, int numpixels) {
  CRGB blue(0, 0, 255);
  CRGB lightBlue( 0, 255, 255);
  for (int i = 0; i < NUMPIXELS; i++) {
    CRGB dest = blend(  blue, lightBlue, inoise8((now) * 17, i * 60));
    leds[i] = dest;
  }
  fadeToBlackBy(leds, NUMPIXELS, map(inoise8(now * 50), 0, 200, 200, 20));
}

void greenFire(uint32_t now, CRGB* leds, int numpixels) {
  CRGB green(0, 150, 0);
  CRGB lightGreen( 153, 250, 51);
  for (int i = 0; i < NUMPIXELS; i++) {
    CRGB dest = blend(  green, lightGreen, inoise8((now) * 17, i * 60));
    leds[i] = dest;
  }
  fadeToBlackBy(leds, NUMPIXELS, map(inoise8(now * 50), 0, 200, 200, 20));
}


void sparkleFire() {
  leds[random(3)] = CRGB::White;
  leds[random(3)] = CRGB::Blue;
  leds[random(3)] = CRGB::Black;
  leds[random(3)] = CRGB::Green;
  leds[random(3)] = CRGB::Yellow;
  leds[random(3)] = CRGB::Red;
  FastLED.setBrightness(175);
  FastLED.show();
  delay(8);
}


void setup() {

  startMillis = millis();
  Serial.begin(115200);
  FastLED.addLeds<NEOPIXEL, PIN>(leds, NUMPIXELS);
  pinMode(PIN, OUTPUT);
 
  myservo.attach(9);
  myservo.write(pos);

 for (int i = 0; i < 3; i++)
  {
    pinMode((buttonPins[i]), INPUT_PULLDOWN);
  }
}


void loop() {

  currentMillis = millis();

  if (stateServo >= 6)
  {
    stateServo = 0;
  }
  buttonPollServo = digitalRead(10);

  if (currentMillis - startMillis < buttonTimer) {
    Serial.println("delay before next Servo button press");
    buttonPollServo = 0;
  }

  else  if (buttonPollServo == 1) {
    delay(100);
    buttonPollServo = digitalRead(10);
    if (buttonPollServo == 1) {
      stateServo = (stateServo + 1);
      startMillis = currentMillis;
      Serial.print("Servo button press  "); Serial.println(stateServo);
      delay(100);
    }
  }

  switch (stateServo) {
    case 1:
      myservo.write(110);
      break;
    case 2:
      myservo.write(120);
      break;
    case 3:
      myservo.write(130);
      break;
    case 4:
      myservo.write(140);
      break;
    case 5:
      myservo.write(150);
      break;
    default:
      myservo.write(100);
      break;
  }

  if (stateLED >= 4)
  {
    stateLED = 0;
  }

  buttonPollLED = digitalRead(12);

  if (currentMillis - startMillis < buttonTimer) {
    Serial.println("delay before next LED button press");
    buttonPollLED = 0;
  }

  else  if (buttonPollLED == 1) {
    delay(50);
    buttonPollLED = digitalRead(12);
    if (buttonPollLED == 1) {
      stateLED = (stateLED + 1);
      startMillis = currentMillis;
      Serial.print("LED button press  "); Serial.println(stateLED);
      delay(100);
    }
  }
  switch (stateLED) {

    case 1:
      blueFire(now, leds, NUMPIXELS);
      FastLED.show();
      delay(DELAYVAL);
      now++;
      break;

    case 2:
      greenFire(now, leds, NUMPIXELS);
      FastLED.show();
      delay(DELAYVAL);
      now++;
      break;

    case 3:
      sparkleFire();
      break;

    default:
      redFire(now, leds, NUMPIXELS);
      FastLED.show();
      Serial.println ("default LED display");
      delay(DELAYVAL);
      now++;
      break;
  }
}


XRAD
 
Posts: 209
Joined: Sat Nov 19, 2016 3:28 pm

Re: XRAD'S FLAMETHROWER

by adafruit_support_mike on Tue Nov 13, 2018 2:25 am

XRAD wrote:Hi Mike,

Something like this:

https://www.youtube.com/watch?v=UCVbqiFf070

Ah.. I think I saw Adam Savage doing something like that on Tested a while back. He used an e-cig and glycerine IIRC. What hardware are you using?

adafruit_support_mike
 
Posts: 55848
Joined: Thu Feb 11, 2010 2:51 pm

Re: XRAD'S FLAMETHROWER

by XRAD on Tue Nov 13, 2018 8:34 am

Same Idea, just more powerful, and can hold as much fluid as I like. The coil is heated by controller in pic below. I build these smoke units out of assorted parts. I also am reworking some vape units to do the same thing, but the coils are small and output not so much unless you buy the 200watt cloud makers, and refilling the little 4oz containers is a PITA. Problem is getting the fog juice to the coil. The best fluid is the party fog juice. you can get a liter for a few bucks.

also see:

https://www.youtube.com/watch?v=-1XEIDR5n4c

There is a huge RC community out there, of which I am part of. I build many crossover devices out of adafruit parts for use in my models.
Attachments
burneffect-21303-1.jpg
burneffect-21303-1.jpg (45.8 KiB) Viewed 279 times

XRAD
 
Posts: 209
Joined: Sat Nov 19, 2016 3:28 pm

Re: XRAD'S FLAMETHROWER

by XRAD on Tue Nov 13, 2018 9:08 pm

I was easily able to move my code off my protoboard processor into the Trinket MO. A few less pins but enough for what I need, and more than enough processor speed. The tutorial pinout chart https://learn.adafruit.com/adafruit-tri ... no/pinouts makes the wiring simple. And the conversion from cricuitpy to arduino/C++ via https://learn.adafruit.com/adafruit-tri ... cuitpython makes this my new favorite version of the Trinket!

XRAD
 
Posts: 209
Joined: Sat Nov 19, 2016 3:28 pm

Re: XRAD'S FLAMETHROWER

by adafruit_support_mike on Wed Nov 14, 2018 3:52 am

If you ever find yourself needing more pins, we have the Seesaw board as a multi-function GPIO expander:

https://www.adafruit.com/product/3657

And for standard GPIO there are always the MCP23008 and MCP23017 GPIO expanders:

https://www.adafruit.com/product/593
https://www.adafruit.com/product/732

adafruit_support_mike
 
Posts: 55848
Joined: Thu Feb 11, 2010 2:51 pm

Re: XRAD'S FLAMETHROWER

by XRAD on Thu Nov 15, 2018 10:18 am

THX for the tip. I missed those nice units! I already have feather MO express on the way and easy to stick on the back of the 2.4" feather touch TFT.

How high can I stack feathers? Will find out soon.....

TFT / MO express / Music Maker / and finally a bigger D amp / and a few Pixies .........It's going to be a Feather Royal with cheese!

XRAD
 
Posts: 209
Joined: Sat Nov 19, 2016 3:28 pm

Re: XRAD'S FLAMETHROWER

by XRAD on Mon Feb 11, 2019 7:13 pm


XRAD
 
Posts: 209
Joined: Sat Nov 19, 2016 3:28 pm

Please be positive and constructive with your questions and comments.