Things used in this project

Hardware components:
11113 01
SparkFun Arduino Pro Mini 328 - 5V/16MHz
×1
Adafruit LIS3DH Triple-Axis Accelerometer
×1

Schematics

firebending schematic
Circuit diagram of the firebending brains. Note that the solenoid is the solenoid valve, and the piezo buzzer is a stand in for the arc lighter.
Firebending schem hufmj1tsrx

Code

firebending.inoC/C++
Arduino sketch for a punch detecting flamethrower.
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>

// Used for software SPI
#define LIS3DH_CLK 13
#define LIS3DH_MISO 12
#define LIS3DH_MOSI 11
// Used for hardware & software SPI
#define LIS3DH_CS 10

//software SPI
Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);

//A fist experiences significant acceleration during a good punch,
//followed by massive deceleration at the end of the punch.
//This happens within a fairly small window of time, so it's
//pretty easy to distinguish a punch from normal gesticulations.

unsigned long punchStart = 0;//variable for non-blocking punch timeframe check
const long punchInterval = 200;//timeframe of a punch in ms, from max acceleration to max deceleration, 200 is very generous
int punchAccel = 20;//the beginning of a punch in m/s^2, could be over 50m/s^2 depending on the puncher
int punchDecel = -40;//the end of a punch in m/s^2, could be less than -100m/s^2 depending on the puncher
int flameTime = 250;//how long the flame lasts, in ms

void setup(void) {
  //Test to see if accelerometer is communicating
  Serial.begin(9600);
  Serial.println("LIS3DH test!");  
  if (! lis.begin(0x18)) {   // change this to 0x19 for alternative i2c address
    Serial.println("Couldnt start");
    while (1);
  }
  Serial.println("LIS3DH found!");
  
  lis.setRange(LIS3DH_RANGE_16_G);   //+-16G range for good punch detection
  Serial.print("Range = "); Serial.print(2 << lis.getRange());  
  Serial.println("G");
  
  pinMode(8, OUTPUT); //Solenoid valve
  pinMode(9, OUTPUT); //Arc lighter
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
}

void loop() {
  lis.read();
  sensors_event_t event; 
  lis.getEvent(&event);
  
 //look for punch starting, at least 20 m/s^2
  if (event.acceleration.x > punchAccel){
     Serial.println(event.acceleration.x);
     punchStart = millis();
  }
  
  unsigned long currentMillis = millis();

  //look for punch ending, less than -40 m/s^2
  if (event.acceleration.x < punchDecel && currentMillis - punchStart < punchInterval){
      Serial.println(event.acceleration.x);
      Serial.println("Punch");
      Fire(flameTime);
    }
}

void Fire(int flameTime){
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  delay(flameTime);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
}

Credits

Myththumb krtcfg2bgz
Allen Pan

My name's Allen, I make pretend things into real things! Watch me do a thing on Youtube!

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

IoT Based Garden Automation And Monitoring System
Advanced
  • 296
  • 9

Full instructions

Automate Your Garden with Arduino and Cayenne

URB (Universal Railway Model Bus)  - Automate Your Layout
Advanced
  • 40
  • 2

Work in progress

All features Arduino, plus: direct plug servos, motor drivers, high-current outputs, built-in I2C bus, convenient connections, and more.

Hank the HexaPod - Mega Bread Robotics Series # 7
Advanced
  • 162
  • 4

Work in progress

After a few months of gathering parts, reading about the new hardware, and ripping my hair out due to no support. I done did it Paw.

Visual Capturing with OV7670 on Arduino
Advanced
  • 4,687
  • 24

Protip

This is an Arduino camera module, using the surveillance camera's digital image processing chip-OV0706.

Get Nostalgic and Use Nokia 84x48 LCD with Arduino
Advanced
  • 3,111
  • 14

Protip

These 84 by 48 pixel LCDs are what you might have found in Nokia 3310. And what about using them in the Arduino projects?

GPS + WiFi Rover
Advanced
  • 1,396
  • 14

Full instructions

An outdoor rover, capable of autonomous navigation (using GPS and sonar sensors) or controlled over WiFi.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog