#include "application.h" #include "neopixel/neopixel.h" SYSTEM_MODE(AUTOMATIC); // IMPORTANT: Set pixel COUNT, PIN and TYPE #define PIXEL_PIN A5 #define PIXEL_COUNT 11 #define PIXEL_TYPE WS2812B Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE); int show = 0; int flash = 0; void setup() { strip.begin(); strip.show(); // Initialize all pixels to 'off' Spark.function("led",ledToggle); } void loop() { switch (show) { case 0: // your hand is nowhere near the sensor off(); break; case 1: // your hand is on the sensor rainbow(30); break; case 2: // your hand is close to the sensor theaterChaseRainbow(700); break; case 3: // your hand is a few inches from the sensor purple(); break; } delay(1); // delay in between reads for stability } int ledToggle(String command) { if (command=="off") { show = 0; return 0; } else if (command=="on"){ show = 1; return 1; } else if (command=="chase"){ show = 2; return 2; } else if (command=="purple"){ show = 3; return 3; } else if (command.indexOf("today") & command.indexOf("wind")){ int firstComma = command.indexOf(','); int secondComma = command.indexOf(',', firstComma + 1 ); purple(); } delay(1); // delay in between reads for stability } void rainbow(uint8_t wait) { uint16_t i, j; for(j=0; j<256; j++) { for(i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(((i * 256 / (strip.numPixels()/3))+j) & 255)); } strip.show(); delay(wait); } //if (flash == 1){ // flash=0; //} else { // flash++; // } } void purple() { uint16_t i; for(i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, strip.Color(100,0,100)); } strip.show(); } void off() { uint16_t i; for(i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, strip.Color(0,0,0)); } strip.show(); } //Theatre-style crawling lights with rainbow effect void theaterChaseRainbow(uint8_t wait) { for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel for (int q=0; q < 2; q++) { for (int i=0; i < strip.numPixels(); i=i+2) { strip.setPixelColor(i+q, Wheel( ((i * 256 / (strip.numPixels()/2))+j) % 255)); //turn every third pixel on } strip.show(); delay(wait); for (int i=0; i < strip.numPixels(); i=i+2) { strip.setPixelColor(i+q, 0); //turn every third pixel off } } } } // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { if(WheelPos < 85) { return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } else if(WheelPos < 170) { WheelPos -= 85; return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } else { WheelPos -= 170; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } }
Asides
The Hammer of Healing and Destruction
The LARP Hammer is a proof of concept that will use electronics to handle game mechanics as well as enhance game emersion by adding lights and sound. The image of the hammer is just an example and only the electronics are being developed for now. This post will be regularly updated with the projects progress.
The Weapon can both heal players as well as deliver powerful blows of devastation. This prop will have no buttons on it except to turn the power on. All actions and attacks will be initiated by wielding the weapon. Using the Adafruit LSM303 sensor, the weapon will track your moments to determine what mode you have selected or how much damage your hit dealt.
This will start out with four attack modes and one healing move.
Using the Hammer
To start the healing mode, you will need to hold the Hammer vertically for 30 seconds (to be set by the DM) without moving more than an inch or so. When the lights on the side turn green and start flashing, swing the hammer and hit the person that is to be healed. When you hear the crashing sound and the lights go out, you have just healed the player but it will not work again for 10 min (to be set by the DM)
A basic hit will register like a basic malay weapons, but only if the hit sound goes off meaning that the hit was hard enough to register.
If the hammer detects a half swing, the hit will be a low power move and count as a +1 hit. This is indicated by an energy discharge sound along with a short flash of light.
When the hammer completes a full 360 swing before hitting, this is a medium power move and counts as a +2 hit. This will make a more energetic sound with a brighter flash.
Three full 360 rotations of the hammer before a hit will activate the power hit delivering a +3 hit and the player that was hit will fall down for 10 seconds. This will make a bigger and long drown out discharge noise with a bright flash of lights. It can only be used 2 min after the last power move.
If you swing the hammer enough times to do the Power Hit, then hold the Hammer up vertically for 5 seconds, the lights will start to flicker and the power up sound will go off. When the lights go solid, slam the bottom of the hammers handle into the ground to activate the Power Move. This will unleash a blinding light and deep energy discharge. Everyone within 10 feet of you will take a malay hit as well as take 5 steps away from you. Once used the hammers energy will be drained and only standard malay hits will be available until it recharges in 10 min. If desired, the number of Power Moves can be limited and more given by using a special “key” that adds more on.
The Electronics
Sound Board Mapping:
- T00HOLDL.OGG – Healing charge for 30 seconds, then hit and discharge.
- T01.OGG – Emergency power up.
- T02.OGG – Ethereal Cry.
- T03.OGG – Ultra Bass Explosion
- T04.OGG – Power up Machine
- T05.OGG – Light Energy weapon
- T06.OGG – Heavy Energy weapon
- T07.OGG – Error sound.
Libraries used:
Sensor: https://learn.adafruit.com/flora-accelerometer/programming
Sound: https://learn.adafruit.com/adafruit-audio-fx-sound-board/serial-audio-control
Pins to be used:
Sound control:
- #5 (TX)
- #6 (RX)
- #4 (RST)
- #8 (ACT)
LEDs:
- #3
Hit Buttons:
- #14 – A0 Hammer Head hit (2 buttons for 1 trigger)
- #19 Bottom Handel hit
- #16 – A2 Copulative touch handle to activate the hammer.
Bluetooth Connection:
- #13
- #12
- #11
- #10
- #9
- #2
Create G-Code from an EAGLE File
Overview
Prototyping a circuit board in this way is a good idea so you can be sure that things are working before sending your PCB off to a fabricator. This method is also a good way to do low run or one off testing PCBs.
G-Code is made up of some simple commands that tell a CNC mill how to move so that your designs come out correctly. This is also called a Tool Path. PCB-GCode is an add-on for EAGLE that lets you create a Tool Path in G-Code so that it can be made by a CNC Mill like my Shapeoko 2. Though there are many ways to create G-Code for PCBs, I will focus on EAGLE and PCB-GCode because they are rather easy to use and the software is free for making basic PCBs Continue reading Create G-Code from an EAGLE File