/dredd-lawgiver

This repo contains the software to bring the Props3D Dredd Lawgiver to life. Working trigger with addressable LEDs, movie sound effects, and screen accurate OLED screen.

Primary LanguageCGNU General Public License v3.0GPL-3.0

dredd-lawgiver V1 - Tested Release

Repository for the Fully Interactive 3D Printable Dredd Lawgiver 2012 from https://www.Props3D.pro/

Download the 3D Models here https://www.thingiverse.com/thing:5199144

Tutorial videos coming soon here: https://www.youtube.com/@Props3D

Licensed under the Creative Commons - Attribution - Non-Commercial - Share Alike license. https://creativecommons.org/licenses/by-nc-sa/4.0/

DO NOT SELL OR DISTRIBUTE MODELS OR CODE WITHOUT PERMISSION

Note that prerelease models have been tested and work, but do not come with instructions or guarantee that everything fits together properly. If you want have feedback please post on our discord(https://discord.gg/NSfZcCfJU6) on the #project-lawgiver channel

Props 3D

Electonic Components

Electronic Components
Arduino Nano v3 DF Player Mini with Micro SD Card
Arduino Nano v3 DF Player Mini + 64mb Micro SD Card
PAM8302A Amp 7 bit LED - Neopixel
Speaker Amp - PAM8302A 7 bit LED - Neopixel (circular, NOT the ring)
30mm 8ohm 2W 7mm Momentary Switch
2 X 30mm 8ohm 2W speaker 7mm momentary switch
Hdffe15eda27b49ba97ad490bd8b2de15D LG_Battery
Mini 560 DC-DC Buck Converter Lipo 7.4v 800mAh
Blue OLED 2.08" 256x64 Voice Recognition Module V3
Blue OLED Display 2.08" 256x64 7Pin SPI Voice Recognition Module V3 from Elechouse
1K Resister 3mm LED Diode
1 X 1K Resister, 2 X 25ohm Resister 3mm LED Diode (Red/Green) x 2

Assembly Parts

Hex Flat Head

  • M3X12mm x 2 - Sights
  • M3X18mm X 2 Electronics Caddy

Hex Cap Head

  • M3X4mm X 6 - Fire LED / Electronics Caddy Voice Reg
  • M3X16mm X3 - Trigger Group, Reload
  • M3X20mm X1 - Reload

Hex CM Flat Head

  • M3X18mm 1 Battery Cap (can be flat head too)

Hex Button Head

  • M3X8mm X2 - Trigger Group to Frame
  • M4X12mm X2 - Barrel

Any head bolt

  • M1.4X4 X4 - Electronics Caddy Arduino

Other Parts

  • 1/8in rod X 9mm X 1 - Trigger axle
  • 1/8in rod x 54mm x 2 - Cocking Mechanism
  • 5/16 X 1 1/8 Extension Spring - Cocking Mechanism
  • 20mm Compression Spring - Magazine latch

Module Assemboly

1 OLED

1 OLED

  • 2.54 JST M 7pin + Pins
  • 2.54 JST F 7pin
  • Wire Black 44mm, 103mm
  • Wire Red 41.5mm, 81mm
  • Wire Green 39mm, 99mm
  • Wire Yellow 36.5mm, 95mm
  • Wire White 33mm, 90mm
  • Wire Blue 30.5mm, 85mm
  • Wire Gray 28mm, 83mm
  • 1mm Heat Shrink 6mm X7

2 Action Module

2 Action Module

  • 7mm momentary switch
  • 2.54 JST 2pin F X2
  • 2.54 JST 2 pin M + Pins
  • Wire White 42mm, 50mm
  • Wire Gray 43mm, 100mm
  • Wire Black 120mm, 160mm
  • Micro Switch R Lever 16mm
  • 2mm Heat Shrink 8mm X2
  • 1mm Heat Shrink 6mm X4

3 Fire LED

3 Fire LED

  • 7 segment LED round
  • 2.54 JST 2pin M + Pins
  • 2.54 JST 1pin M + Pin
  • Wire Yellow 140mm
  • Wire Black 90mm
  • Wire Red 90mm

4 Boot LEDs

4 Boot LEDs

  • 3mm Red LED
  • 3mm Green LED
  • 2x 25 Ohm resister
  • 2.54 JST 3pin M + Pins
  • 2.54 JST 3pin F
    • Wire Black 22mm, 27mm, 66mm
  • Wire Purple 30mm, 50mm
  • Wire Blue 30mm, 50mm
  • 1mm Heat Shrink 6mm X10

5 Power

5 Power

  • Deans Plug M
  • Mini 560 Buck
  • 15X10mm Rocker Switch
  • Wire Black 70mm, 310mm
  • Wire Red 14mm, 64mm, 310mm
  • 23mm Heat Shrink 27mm
  • 3mm Heat Shrink 10mm X2
  • 3mm Heat Shrink 8mm X2

6 Sound

6 Sound

  • DF Player Mini
  • Amp PAM8302A
  • 64MB+ Micro SD
  • 1k Resister
  • 2.54 JST 2pin M + Pins
  • Wire Gray 42mm
  • Wire White 43mm
  • Wire Purple 26mm
  • Wire Blue 26mm
  • Wire Black 22mm, 66mm
  • Wire Red 33mm, 67mm
  • 1mm Heat Shrink 6mm

7 Power Junction Box

7 Power Junction Box

  • Breadboard
  • 2.54 JST 2pin F X6
  • 26~30 AWG Solid Copper Wire 44mm, 49mm

8 Voice Recognition

8 Voice Recognition

  • Voice Recognition Module V3
  • 2.54 JST 2pin M + Pins
  • Wire Black 35mm
  • Wire Red 36mm
  • Wire Gray 40mm
  • Wire White 44mm

9 Arduino

9 Arduino

  • Arduino 328p
  • 2.54 JST 2pin M + Pins
  • 90deg IC Pin
  • Wire Black 56mm
  • Wire Red 56mm

10 Speaker

10 Speaker

  • 30mm Speaker X2
  • Wire Purple 25mm, 65mm
  • Wire Blue 25mm, 65mm

Arduino Pinout

  • D2 Voice Recognition RX
  • D3 Voice Recognition TX
  • D4 DF Player Mini RX
  • D5 DF Player Mini TX
  • D6 3mm LED GREEN
  • D7 3mm LED RED
  • D8 Trigger
  • D9 Reload
  • D10 OLED RST
  • D11 OLED DC
  • D12 OLED CS
  • A4 OLED SDA
  • A5 OLED SCL
  • D13 FIRE LED

Required Libraries

There's are number of libraries that you will need to install using the Arduino Library Manager:

  1. U8g2 - modified with the necessary changes
  2. FastLED
  3. ezButton

All of these are included in the libraries directory. Copy each one into your /Arduino/libraries directory, make backups of any you have installed already in case you need to put them back for other projects.

Installing U8g2 and required modifications

If you want to install and use the latest version of the U8G2 library, then follow these instructions.

The U8g2 library has a pretty large program foot print, so we need to make a number of changes to minimize the size of the program. See https://github.com/olikraus/u8g2/wiki/u8g2optimization for details.

  1. Open /Arduino/libraries/u8g2/src/clib/u8g2.h
  2. Comment out following lines to reduce program size
    • #define U8G2_WITH_INTERSECTION
    • #define U8G2_WITH_CLIP_WINDOW_SUPPORT
    • #define U8G2_WITH_FONT_ROTATION

If you are using the same SH1122 OLED compoment, you'll want to try an minimize the noise of the OLED by reducing it's refresh rate and various voltages. Spec sheet include the supported commands: https://www.displayfuture.com/Display/datasheet/controller/SH1122.pdf

  1. Open /Arduino/libraries/u8g2/src/clib/u8x8_d_sh1122.c
  2. Find and replace the setting for clock divide ratio and fosc (0xD5)
    • U8X8_CA(0xd5, 0x50) should be U8X8_CA(0xd5, 0x31)
  3. Find and replace the setting for pre-charge (0xDC)
    • U8X8_CA(0xdc, 0x35) should be U8X8_CA(0xdc, 0x1a)

Voice Recognition module

If you want to install and use the latest version of the VoiceRecognitionV3 library, then follow these instructions.

The voice recognition module is from Elechouse. Their library has to be installed manually to the Arduino library, and can be found on Github.

  1. Open https://github.com/elechouse/VoiceRecognitionV3
  2. Download the zip or clone the repo
  3. Extract contents into the /Arduino Sketch/libraries directory

Once installed, follow the instructions to train the VR module. You can train up to 7 active voice commands. Train each command using the example sketche that comes with the library. You can find detailed instructions in the manual or the VoiceRecognitionV3 github page, but here's a few tips to make you successful:

  1. Make sure to change the RX and TX pin based on how you connected it to the Arduino
  2. The commands should be trained based on the programs expected order - defined in config.h
  3. Once all of the commands are trained, update the module to autoload the commands on startup
    • This step is crucual to make the VR module work with this sketch.

Training commands

There are two options to train the voice recogition commands.

The easiest option is load the vr_module_cmd_training sketch.

  1. Open the extras/vr_module_cmd_training sketch
  2. Set the correct RX/TX pins numbers to match your wiring.
  3. Choose right Arduino board (Tool -> Board, Arduino Nano recommended), Choose right serial port.
  4. Click Upload button, wait until Arduino is uploaded.
  5. Open Serial Monitor. Set baud rate 115200, set send with Newline or Both NL & CR.
  6. Read and follow the instructions
  7. The script will prompt you to record each command / phrase - one at a time
  8. When ready, press enter to begin recording
    • When Serial Monitor prints "Speak now", you need speak the command
    • When Serial Monitor prints "Speak again", you need repeat the command again.
    • If these two voice commands are matched, Serial Monitor prints "Success", and "record X" is trained
    • or if are not matched, repeat the process until success.
  9. Training will be completed when you record all 7 commands successfully
  10. At this point, you can test the training by speaking the commands
  11. Follow the next section to enable autoloading of the trained recordings

The second option is to use the example sketch that is packaged with VoiceRecognitionV3 library. The voice commands must be trained in the expected slots. The order is defined in the config.h file and should not be changed. For reference, see below:

/**
 *  Voice Recognition Commands.
 *  IMPORTANT - The VR module must be trained this sequence.
 */
#define VR_CMD_AMMO_MODE_AP         0 // speak "Armor Piercing" or just "Armor"
#define VR_CMD_AMMO_MODE_IN         1 // speak "Incendiary"
#define VR_CMD_AMMO_MODE_HS         2 // speak "Hotshot"
#define VR_CMD_AMMO_MODE_HE         3 // speak "High Ex"
#define VR_CMD_AMMO_MODE_ST         4 // speak "Stun"
#define VR_CMD_AMMO_MODE_FMJ        5 // speak "Full Metal"
#define VR_CMD_AMMO_MODE_RAPID      6 // speak "Rapid"

You can find instructions, with pictures, on the VoiceRecognitionV3 Github page.

  1. Open vr_sample_train (File -> Examples -> VoiceRecognitionV3 -> vr_sample_train)
  2. Choose right Arduino board (Tool -> Board, Arduino Nano recommended), Choose right serial port.
  3. Click Upload button, wait until Arduino is uploaded.
  4. Open Serial Monitor. Set baud rate 115200, set send with Newline or Both NL & CR.
  5. Check the Voice Recognition Module settings. Input settings
    • Enter command: settings
    • Hit Enter to send.
  6. Train Voice Recognition Module.
    • To train record 0, enter command: train 0
    • When Serial Monitor prints "Speak now", you need speak your command
    • When Serial Monitor prints "Speak again", you need repeat your command again.
    • If these two voice commands are matched, Serial Monitor prints "Success", and "record 0" is trained
    • or if are not matched, repeat speaking until success.
  7. Repeat the process for each command i.e. train 1, train 2, train 3, etc
    • check out the config.h file for the order and phrases to follow
  8. Once all the commands are recorded, load and test the voice commands
    • To load all 7 voice commands, enter command: load 0 1 2 3 4 5 6
    • Speak the command to see if the Voice Recognition Module can recognize your words.
    • When recognized it will display the VR index
  9. If some of the commands don't work well, you can re-train until you're satisfied
  10. Training complete
  11. Follow the next section to enable autoloading of the trained recordings

Configuring Autoload feature

There are two options to enable the autoloading trained commands on startup.

The easiest option is load the vr_module_set_autoload sketch.

  1. Open the extras/vr_module_set_autoload sketch
  2. Set the correct RX/TX pins numbers to match your wiring
  3. Upload the sketch to the Arduino
  4. Open the Serial Monitor. Set baud rate 115200
  5. Wait until it says Power Down and unplug

The second option is to use the example sketch that is packaged with VoiceRecognitionV3 library.

  1. Open the vr_sample_bridge sketch
  2. Set the correct RX/TX pins numbers to match your wiring
  3. Upload the sketch to the Arduino
  4. Open the Serial Monitor. Set baud rate 115200, set send with Newline or Both NL & CR.
  5. Enter command: 00
    • you should see output like: AA 08 00 00 00 00 00 00 00 0A
  6. Enter command: 15 7F 00 01 02 03 04 05 06
    • This tells the boards to autoload 7 records and which trained slots to load
  7. Enter command: 00
    • you should see output like: AA 08 00 00 00 00 00 7F 00 0A

If you can't get the autoload feature configured, you could uncomment code in the EasyVoice.begin() function to manually load each record on startup. Recommend avoiding this if possible, it may slow the startup sequence or have other unintended problems. That part is untested.

Setup and Configuration

The component configurations can be easily customized by updating the values in config.h based on your components, wiring, and audio tracks.

// To disable any component set value to 0
#define ENABLE_DEBUG            0 //Enable Debugging
#define ENABLE_EASY_AUDIO       1 //Enable audio
#define ENABLE_EASY_LED         1 //Enable LEDs
#define ENABLE_EASY_OLED        1 //Enable OLED Display
#define ENABLE_EASY_VOICE       1 //Enable Voice Recognition
#define ENABLE_EASY_BUTTON      1 //Enable triggers


// Customizable ID badge for DNA Check sequence 
const char DISPLAY_USER_ID[] PROGMEM =      {"Dredd"};


// Pin configuration for voice recognition module
#define VOICE_RX_PIN          2
#define VOICE_TX_PIN          3

// Pin configuration for MP3 Player
#define AUDIO_RX_PIN          4
#define AUDIO_TX_PIN          5

// Pin Configuration for 3mm LEDs
#define GREEN_LED_PIN         6
#define RED_LED_PIN           7

// Pin configuration for all momentary triggers
#define TRIGGER_PIN           8
#define RELOAD_PIN            9

// Pin configuration for oled display
#define OLED_SCL_PIN          A5
#define OLED_SDA_PIN          A4
#define OLED_RESET_PIN        10
#define OLED_DC_PIN           11
#define OLED_CS_PIN           12


// Pin configuration for front barrel WS2812B LED
// set these to 0 if you want to disable the component
#define FIRE_LED_PIN          13
#define FIRE_LED_CNT          7

Audio File Setup

The DF Mini Player will play back both mp3 and wav files. However, the program play back tracks based on index. The index is determined by the order the files are loaded onto the card. It also expects all files to be loaded into a sub directory on the card called "/mp3".

When using a MAC to load files, it will create hidden files that will cause the playback to seem like it's not working. You'll need to use the terminal window to rm all of these files and directories from the card.

The audio file indices are listed in the config.h file. Do not remove any of the entries. You can reuse sound effects for each slot with two options:

  1. Copy the audio file in each slot where you want to use it
  2. Change the index values below to match the files on the SD Card

I followed option 1 for the included audio files in this repo, it's just easier and there's plenty of room on the micro SD card.

/**
 * Audio tracks by file index - upload these to the SD card in the correct order.
 */
static const int  AUDIO_TRACK_DNA_CHK      =   1;
static const int  AUDIO_TRACK_ID_OK        =   2;
static const int  AUDIO_TRACK_ID_FAIL      =   3;
static const int  AUDIO_TRACK_AMMO_LOAD    =   4;
static const int  AUDIO_TRACK_AP_FIRE      =   5;
static const int  AUDIO_TRACK_IN_FIRE      =   6;
static const int  AUDIO_TRACK_HS_FIRE      =   7;
static const int  AUDIO_TRACK_HE_FIRE      =   8;
static const int  AUDIO_TRACK_ST_FIRE      =   9;
static const int  AUDIO_TRACK_FMJ_FIRE     =   10;
static const int  AUDIO_TRACK_RAPID_FIRE   =   11;
static const int  AUDIO_TRACK_AP_CHANGE    =   12;
static const int  AUDIO_TRACK_IN_CHANGE    =   13;
static const int  AUDIO_TRACK_HS_CHANGE    =   14;
static const int  AUDIO_TRACK_HE_CHANGE    =   15;
static const int  AUDIO_TRACK_ST_CHANGE    =   16;
static const int  AUDIO_TRACK_FMJ_CHANGE   =   17;
static const int  AUDIO_TRACK_RAPID_CHANGE =   18;
static const int  AUDIO_TRACK_AMMO_LOW     =   19;
static const int  AUDIO_TRACK_AMMO_EMPTY   =   20;
static const int  AUDIO_TRACK_AMMO_RELOAD  =   21;
static const int  AUDIO_TRACK_SILENCE      =   22;
static const int  AUDIO_TRACK_THEME        =   23;  // TODO: add feature to playback theme

Example Wiring Diagram:

SampleWiring

Test Board Reference Design

Lawgiver

Painting Guide

Top:

  • Base: Matte Black Primer
  • Underlayer: Tamiya Gun Metal
  • Primary: Tamiya Semi-Gloss Black
  • Top Coat: Satin

Body:

  • Base: Matte Black Primer
  • Primary: Tamiya Flat Black
  • Top Coat: Matte

Barrel/Trigger/Suppressor:

  • Base: Matte Black Primer
  • Primary: Tamiya Semi-Gloss Black
  • Top Coat: Satin

Bullets:

  • Base: Matte Black Primer
  • Underlayer: Antique Brass (only bullets)
  • Primary: Brass
  • Primary: Copper (only rings)
  • Top Coat: Satin

Assembly Guide.. in pictures!

Starting point

Frame is glued together, electroincs are all soldered to match pictures above

Trigger and Slide

LG_Step1

Attach all the electronics module to the caddy in the following configuration. The MP3 and Amp are attached with double sided tape

LG_Step2

Screw the two caddy sides together

LG_Step3

Insert the 4mm pin in the trigger and the switch as shown

LG_Step4

Screw the two haves of the trigger group together

LG_Step5

These are the parts for the slide

LG_Step6

Drill the switch holes out with a 3mm bit

LG_Step7

The switch should stick out like this, you may want to give it a teeny bend to make it more clicky

LG_Step8

Insert the spring between the two posts, you may have to take some loops off, make sure theres enough tension that the it stays all the way closed when the switch is in

LG_Step9

Insert the guide rods

LG_Step10

Trigger and switch are ready to go!

Frame

LG_Step11 SCrew the LED in, you may have to sand the edge of the LED since some of them have bits that stick out from manufacturing

LG_Step12 Insert the LEDs like this, make sure they'll clear the channel for the OLED retainer

LG_Step13 You'll have to rock the switch in place to fit, it's very tight for a reason. Insert it from the front and snap it past the two posts, the edges are rounded for this reason. After screw it in place.

LG_Step14 Inser the OLED and the OLED retainer, make sure the wires don't get caught when you slip it in. It's tight!

LG_Step15 View from the other side

LG_Step16 Inser the spring and the magazine catch

LG_Step17 Rotate the release pin for the catch and insert the stopper in the hole to prevent the release from getting stuck.

LG_Step18 Inser the 25mm lens into the barrel and the lens holder beside it, make sure the slot lines up

LG_Step19 Power switch clicks into place, make sure on is forward.

LG_Step20 Solder the power to the switch AFTER it's in place, I also put double tape on the buck converter to keep it in place.

LG_Step21 Insert the battery this way up, it does go the other way but you won't have easy access to the charge port.

LG_Step22 Easy charge port access, you can screw the heel on now.

LG_Step23 These 4 wires go through teh channel on the cocking mechanism and through this small channel, don't pinch anything! If the cocking mechanism isn't flush you have a pinched wire.

LG_Step24 All flush and snug don't force it unless you like resoldering ripped wires!

LG_Step25 Take the two havles of the caddy apart to connect the fire LED data wire, put it back together after

LG_Step26 Plug all the wires into the distrubution box and give it a whirl. This is your last chance to test it!

LG_Step27 The OLED connector goes here, stuffing it anywhere else will jam the top

LG_Step28 See? Nice and snug

LG_Step29 Inser the barrel and make sure the holes line up really well

LG_Step30 Put the front cover on and screw it together

LG_Step31 Lining this little hole up from the top cover to the frame is important

LG_Step32 Screw it loosly and slip the rear cover in place.

LG_Step33 And screw it all down

Magazine

LG_Step34 I will update this pic later, bullets go the other way up!, but just rest it here lightly to start

LG_Step35 Insert the side panel holder and the side panels then slide them all down as one unit. I had to 'slide it' with a small mallet.

LG_Step36 Needs to be totally flush on top or the mag won't insert!

LG_Step37 Pretty!

LG_Step38

Now go serve some justice!