{"id":1516,"date":"2018-02-20T17:24:38","date_gmt":"2018-02-20T15:24:38","guid":{"rendered":"http:\/\/borkedcode.com\/wp\/?p=1516"},"modified":"2018-02-20T17:24:38","modified_gmt":"2018-02-20T15:24:38","slug":"the-uss-enterprise-refit-from-star-trek-the-motion-picture-16","status":"publish","type":"post","link":"https:\/\/borkedcode.com\/wp\/?p=1516","title":{"rendered":"The USS Enterprise (Refit) from Star Trek: The Motion Picture"},"content":{"rendered":"<h1>Build Log: \u00a0Part 16<\/h1>\n<p>Well, hi!<\/p>\n<p>First off, I feel an apology is necessary here \u2013 I haven\u2019t updated my log in a LONG time, and I should have.\u00a0 I\u2019m sorry.\u00a0 Since last we spoke, I\u2019ve had a move across the country to Munich and started a new job with a cool biotech firm, and that\u2019s been occupying a big chunk of my time.\u00a0 I haven\u2019t had the kind of space or free time to do the Enterprise justice, so I have been doing some Delphi coding and a couple of ocean-going ship models in the limited environment I\u2019ve had.<\/p>\n<p>However, I have a proper man-cave now, and I\u2019ve been able to make some progress, so it\u2019s time for an update!<\/p>\n<p>In trials with that little Chinese MP3 player, I discovered that the power output from a PC USB port is anything but steady, and this resulted in the player re-setting itself at random intervals.\u00a0 This had a really awful effect on my attempts to code a solution for the Big E, and I eventually scrapped it.\u00a0 I didn\u2019t find out about the voltage problem until well after I\u2019d soldered together a very nice transistor setup on that board I showed you, and while the player was having fits being plugged into my laptop, I was left thinking I\u2019d screwed something up in my soldering.\u00a0 As it turns out, I had everything right, but the player just wasn\u2019t up to the job.<\/p>\n<p>So let\u2019s talk about that player for a bit \u2013 given its sensitivity to voltage changes, it really isn\u2019t a good choice for a model that has more than one sound.\u00a0 If you\u2019ve got just one sound or some background noise, it\u2019s probably a solid play.\u00a0 But for what I have in mind, it just won\u2019t cut the mustard.<\/p>\n<p>Instead, I went looking for, and retrieved, several different MP3 options.\u00a0 My favorite so far, and one that <em>does<\/em> work for this job, is this:<\/p>\n<div id=\"attachment_1518\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DF3Chip.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1518\" class=\"size-medium wp-image-1518\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DF3Chip-300x288.jpg\" alt=\"\" width=\"300\" height=\"288\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DF3Chip-300x288.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DF3Chip.jpg 324w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1518\" class=\"wp-caption-text\">All the power of an MP3 player in about 1.5cm square.<\/p><\/div>\n<p>It takes a micro-SD card, just like these little players, and is only just barely larger than one.\u00a0 It\u2019s called a \u201cDFPlayer Mini\u201d, and you can get them dirt-cheap on eBay.\u00a0 Reference materials are widely available on the web, and they\u2019re very easy to control from an Arduino.<\/p>\n<p>Before I start digging into the Arduino code, I want to go into the soldering and setup of a PCB board with you first (skip ahead if this isn\u2019t of interest to you).<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>I\u2019m not a professional electrician, so if you have access to one, take their advice ahead of mine.\u00a0 I\u2019ve found this set of methods to be very useful, and feel it\u2019s my duty to share.<\/p>\n<p>Get the right size PCB board first \u2013 PCB means \u201cprinted circuit board\u201d, by the way, it\u2019s not some magic acronym or anything.\u00a0 You want to accommodate not only your parts, but your fingers too. Try to imagine where it\u2019s going to be mounted (in the model? in the base?) and what kind of height you\u2019ll have available.<\/p>\n<p>I\u2019ll probably design my base with an inch or two of height in it, and since this model is so huge there will probably be some very big empty spaces in the base\u2026so that\u2019s where I\u2019ll stick most of my controlling systems.\u00a0 The TrekModeler board will go in the secondary hull, so I won\u2019t have a kajillion wires going up-and-down the post.<\/p>\n<p>You\u2019re going to need wire \u2013 at least two different colors of insulated wire, and preferably one more spool of non-insulated.\u00a0 (Non-insulated tends to be a little stiffer, too, which makes it useful for creating false \u2018legs\u2019 for soft wires during your breadboard testing.)\u00a0 These shouldn\u2019t cost you a whole lot, and can be had from Radio Shack, Conrad, or bought online.\u00a0 Leftover speaker wire can work, but that can be a bit thick for this purpose, and hard to work with.<\/p>\n<p>Some needle-nose pliers are also going to come in handy, although you could probably use a wooden chop-stick from takeout Chinese to get this job done too.\u00a0 Wire snips are a big help (kitchen scissors work, but are kinda large and you might end up blunting them).<\/p>\n<p>Many electrical parts require properly-metered resistors to go with them, and of course longer wires from the board to reach your lights and so on.\u00a0 Although it is possible to mount them on a PCB and thread all the \u201cfeet\u201d together, I find that using little \u2018horseshoes\u2019 of uninsulated wire to connect the parts makes things slightly clearer when looking at the board.\u00a0 For some reason, I also find it easier to get my parts to sit more cleanly when using horseshoes.<\/p>\n<p>To make a horseshoe, just take some uninsulated wire and wrap it around one point of your needlenose pliers (or a chop-stick) and snip off the excess.\u00a0 Using those needlenose pliers, you can then grip the horseshoe by its middle and insert the legs into the holes on the PCB you want them in.<\/p>\n<div id=\"attachment_1519\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2385-resized.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1519\" class=\"size-medium wp-image-1519\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2385-resized-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2385-resized-300x225.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2385-resized-768x576.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2385-resized-1024x768.jpg 1024w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2385-resized.jpg 1824w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1519\" class=\"wp-caption-text\">Grab the wire with pliers, end flush to one side&#8230;<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_1520\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2386-resized.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1520\" class=\"size-medium wp-image-1520\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2386-resized-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2386-resized-300x225.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2386-resized-768x576.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2386-resized-1024x768.jpg 1024w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2386-resized.jpg 1824w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1520\" class=\"wp-caption-text\">Gripping the wire tight, roll the pliers so the wire folds flush against them at about the right thickness to match the holes on your PCB&#8230;<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_1521\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2387-resized.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1521\" class=\"size-medium wp-image-1521\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2387-resized-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2387-resized-300x225.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2387-resized-768x576.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2387-resized-1024x768.jpg 1024w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2387-resized.jpg 1824w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1521\" class=\"wp-caption-text\">This makes a little &#8220;hook&#8221;.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_1522\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2388-resized.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1522\" class=\"size-medium wp-image-1522\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2388-resized-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2388-resized-300x225.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2388-resized-768x576.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2388-resized-1024x768.jpg 1024w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2388-resized.jpg 1824w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1522\" class=\"wp-caption-text\">Snip off to have even legs.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_1523\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2389-resized.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1523\" class=\"size-medium wp-image-1523\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2389-resized-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2389-resized-300x225.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2389-resized-768x576.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2389-resized-1024x768.jpg 1024w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2389-resized.jpg 1824w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1523\" class=\"wp-caption-text\">It&#8217;s easy to make quite a few in advance, so they&#8217;re ready when you need them.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_1526\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2392-resized.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1526\" class=\"size-medium wp-image-1526\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2392-resized-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2392-resized-300x225.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2392-resized-768x576.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2392-resized-1024x768.jpg 1024w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2392-resized.jpg 1824w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1526\" class=\"wp-caption-text\">When used, they make a nice clean look.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>When soldering, a key rule to remember is \u201cless is more\u201d.\u00a0 You only want to use just enough solder to fill the hole in the PCB and cement the legs of the parts inside it.<\/p>\n<div id=\"attachment_1524\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/GoodSolder.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1524\" class=\"size-medium wp-image-1524\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/GoodSolder-300x150.jpg\" alt=\"\" width=\"300\" height=\"150\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/GoodSolder-300x150.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/GoodSolder-768x383.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/GoodSolder-1024x511.jpg 1024w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/GoodSolder.jpg 1159w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1524\" class=\"wp-caption-text\">Good solder looks like this.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>You don\u2019t want a great big glob on the board, and you absolutely don\u2019t want spill-over to connect other parts of the board (these are called \u201cshorts\u201d \u2013 they\u2019re responsible for the term \u201cshort circuit\u201d, which is generally an undesirable connection that can potentially damage your components).<\/p>\n<div id=\"attachment_1525\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/BadSolder.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1525\" class=\"size-medium wp-image-1525\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/BadSolder-300x185.jpg\" alt=\"\" width=\"300\" height=\"185\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/BadSolder-300x185.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/BadSolder-768x474.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/BadSolder.jpg 962w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1525\" class=\"wp-caption-text\">Bad solder, on the other hand, can look like that.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>I went into a little detail in my last installment about how the functions of the program are going to work\u2026but after looking it over I\u2019m going to have to be more detailed than that in order to ensure I don\u2019t bork something up completely.\u00a0 It\u2019s going to be a rather extensive wiring setup, and I\u2019ll use one other 3<sup>rd<\/sup>-party item, a lighting board from TrekModeler (at least, I think I\u2019m going to use that \u2013 I haven\u2019t run current through it yet, so at this point I\u2019m assuming that it will do the job I want) to handle the lightup and power-down.<\/p>\n<p>Some of this may get a little tedious, but you really have to be tedious when you\u2019re designing an embedded software program with electronics \u2013 once it\u2019s in, you aren\u2019t going to get much chance to change it.\u00a0 (Where I position the controller will make this easier, but let\u2019s assume for the sake of argument that you aren\u2019t going to have that option.)<\/p>\n<p>Here are the main routines as I envision them:<\/p>\n<ul>\n<li>Startup \u2013 initialize everything to idle<\/li>\n<li>Sleep \u2013 put the model to sleep<\/li>\n<li>Wake \u2013 wake it up from sleep<\/li>\n<li>Event \u2013 button got pressed, or some other trigger occurred\n<ul>\n<li>Check to see if event end time is here \u2013 if so, switch to idle<\/li>\n<\/ul>\n<\/li>\n<li>Reset \u2013 shut down anything currently going on and re-intialize<\/li>\n<li>PowerUp \u2013 perform main-sequence music and lights<\/li>\n<li>Power-down \u2013 shut down completely<\/li>\n<li>BattleStations \u2013 Toggle (Red Alert on, or standing down from)\n<ul>\n<li>Makes Fire commands available<\/li>\n<\/ul>\n<\/li>\n<li>FireTorps \u2013 torpedoes fire<\/li>\n<li>FirePhasers \u2013 phasers fire<\/li>\n<li>Warp Toggle \u2013 go to warp or return from it (sound and lights)<\/li>\n<\/ul>\n<p>Routines that aren\u2019t going to be invoked by user choice, but will be needed, include:<\/p>\n<ul>\n<li>MP3 controls\n<ul>\n<li>Play (int Track)<\/li>\n<li>Pause<\/li>\n<li>Next<\/li>\n<li>Prev<\/li>\n<li>Volume<\/li>\n<\/ul>\n<\/li>\n<li>Check PlayTime (This determines how long the model has been active \u2013 because of a limit in the clock of the Arduino, it rolls over after about ~50 days. Since most of my tracks are timed to sequence with lights, I need to reset my timing if it has rolled over.)<\/li>\n<\/ul>\n<p>These functions will revolve around physical components in the model, which consist of lights, and available sound resources, stored on the SD card in the chip\u2019s socket.\u00a0 The lights, listed out as circuits, are:<\/p>\n<ul>\n<li>Warp engine interiors, engine crystals, deflector dish (blue), and the impulse crystal<\/li>\n<li>Impulse engines, deflector dish (amber), and impulse crystal<\/li>\n<li>Interior lighting<\/li>\n<li>Floods\n<ul>\n<li>Upper primary hull<\/li>\n<li>Lower primary hull<\/li>\n<li>Secondary hull sides<\/li>\n<li>Front engines<\/li>\n<li>Rear engines<\/li>\n<li>Pylons<\/li>\n<li>Neck<\/li>\n<\/ul>\n<\/li>\n<li>Nav lights (the slow-blinking ones on the sides and front of the primary hull)<\/li>\n<li>Anti-collision (fast-blinking on primary and secondary hull)<\/li>\n<li>Shuttle bay<\/li>\n<li>Torpedo room (when ready to fire, the launchers show red)<\/li>\n<li>Torpedo launchers<\/li>\n<li>Phasers<\/li>\n<\/ul>\n<p>Sound resources on the SD card are:<\/p>\n<ul>\n<li>Ambient\/idle<\/li>\n<li>Warp<\/li>\n<li>Torpedo fire<\/li>\n<li>Phaser fire<\/li>\n<li>Red Alert<\/li>\n<li>Startup Music<\/li>\n<\/ul>\n<p>We\u2019ll now build a \u201cuser story\u201d to indicate what the model does in response to user action, and when it is able to do what.<\/p>\n<ol>\n<li>User turns on power\n<ol>\n<li>Initialization \u2013 turn on the MP3 player, turn on the extra board, enable any lights that are not subject to controls<\/li>\n<\/ol>\n<\/li>\n<li>Arduino program loop begins:\n<ol>\n<li>Check sleep timeout \u2013 if the model has been awake and no one has touched it in a while, put it to sleep<\/li>\n<li>Check total playtime (50-day runout of counter, make sure we don\u2019t overrun that clock in the controller\u2019s CPU)<\/li>\n<li>Check to see if the user asked for an action\n<ol>\n<li>If so, perform that action<\/li>\n<\/ol>\n<\/li>\n<li>Is there an action running?\n<ol>\n<li>Has its time run out?\n<ol>\n<li>If so, return model to idle state\n<ol>\n<li>Basic Power: interior lights, shuttle bay<\/li>\n<li>Play idle sound<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>The user can ask for certain functions only at certain times \u2013 for example, firing a torpedo can only be done after going to Battle Stations\/Red Alert.\u00a0 Here\u2019s the breakout of how those functions relate to one another, and which ones become available when:<\/p>\n<ul>\n<li><u>Initialization<\/u> \u2013 this is the root event on which all others depend\n<ul>\n<li><u>PowerUp<\/u>\n<ul>\n<li>Play intro music, switch to ambient after done<\/li>\n<li>Lighting sequence:<\/li>\n<li>Bridge<\/li>\n<li>Pylons<\/li>\n<li>Engine forward<\/li>\n<li>Neck floods<\/li>\n<li>Engine aft<\/li>\n<li>Aux control<\/li>\n<li>2ndary hull sides<\/li>\n<li>Deflector dish to impulse<\/li>\n<li>Nav and anticollision somewhere in there<\/li>\n<li>Events available:\n<ul>\n<li><u>Power-down<\/u> (reduce lighting to state like just after initialization)\n<ul>\n<li>This plays the ambient noise<\/li>\n<\/ul>\n<\/li>\n<li><u>Sleep<\/u>\n<ul>\n<li>Turns off sound<\/li>\n<li>All lights turned off<\/li>\n<li>Available functions:\n<ul>\n<li><u>Wake<\/u>\n<ul>\n<li>This is same as \u201cinitialize\u201d<\/li>\n<\/ul>\n<\/li>\n<li><u>Warp<\/u> on\/off\n<ul>\n<li>Play warp sound<\/li>\n<li>Switch impulse engines off<\/li>\n<li>Change deflector dish and impulse crystal to blue<\/li>\n<li>Start warp engine interior and crystals<\/li>\n<\/ul>\n<\/li>\n<li><u>BattleStations<\/u> on\/off\n<ul>\n<li>Play Red Alert sound, ambient sound after that<\/li>\n<li>Turn on torpedo bay backlight<\/li>\n<li>Available functions:\n<ul>\n<li><u>Fire torpedoes<\/u>\n<ul>\n<li>Play torpedo sound<\/li>\n<li>Lights to fire tube 1<\/li>\n<li>Play torpedo sound<\/li>\n<li>Lights to fire tube 2<\/li>\n<\/ul>\n<\/li>\n<li><u>Fire phasers<\/u>\n<ul>\n<li>Play phaser sound<\/li>\n<li>Alternate phasers on\/off while sound is going<\/li>\n<\/ul>\n<\/li>\n<li><u>Return to normal<\/u> (I\u2019m also going to include a five-minute timeout so that after five minutes of no action while at Red Alert, the ship will return to normal state)\n<ul>\n<li>Returns to powered-up idle state<\/li>\n<li>Powers down weapons<\/li>\n<li>Play ambient sound<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>To accomplish all this, we\u2019re going to need wiring, software, and some work.<\/p>\n<p>With any wired system, I recommend you first assemble your wiring harness outside of the model, using a breadboard and jumper wires with sample LEDs.\u00a0 You\u2019ll save yourself a lot of tears if you do this first, because if you don\u2019t, and you make any kind of error, you\u2019ll have to either fix it or live with it, and both of those are painful.<\/p>\n<p>To help, there are quite a few apps available free online that can help you.\u00a0 I\u2019ve used one called \u201cFritzing\u201d to help me put together my picture of what will be needed to connect to my Arduino.<\/p>\n<p>I still intend to use a Nano, by the way, but it\u2019s easier to visualize in the Fritzing interface using an Uno.\u00a0 Here\u2019s what I came up with:<\/p>\n<div id=\"attachment_1527\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/Wiring-Layout.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1527\" class=\"size-medium wp-image-1527\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/Wiring-Layout-300x242.jpg\" alt=\"\" width=\"300\" height=\"242\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/Wiring-Layout-300x242.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/Wiring-Layout-768x620.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/Wiring-Layout.jpg 837w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1527\" class=\"wp-caption-text\">My breadboard layout. I use this to guide myself through the physical circuitry.<\/p><\/div>\n<p>Note that I\u2019m only including a single LED attached to the TrekModeler board in this diagram \u2013 there are many more, but I didn\u2019t feel it necessary to lay them all out here.\u00a0 This board also comes with two momentary switches, which are intended to be mounted on the model\u2019s base and can control the power-up and warp-impulse switching.\u00a0 I\u2019m going to use transistors that are under the control of my Arduino as momentaries here, in effect my software will pretend to be the finger pushing the button.<\/p>\n<p>I also have a little old PC speaker connected to the system for testing.\u00a0 I\u2019ll change that for a headphone jack when it goes into the real base.<\/p>\n<p>This diagram does not show my phaser setup, which will connect pins A2 and A3 as my phaser controls.<\/p>\n<p>When assembled on a board with the TrekModeler controls all hooked up, the entire thing looks a bit like this:<\/p>\n<div id=\"attachment_1528\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2500-resized.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1528\" class=\"size-medium wp-image-1528\" src=\"http:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2500-resized-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2500-resized-300x225.jpg 300w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2500-resized-768x576.jpg 768w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2500-resized-1024x768.jpg 1024w, https:\/\/borkedcode.com\/wp\/wp-content\/uploads\/2018\/02\/DSCF2500-resized.jpg 1824w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1528\" class=\"wp-caption-text\">The whole schmear wired together. I&#8217;m still a little afraid to add power until I&#8217;ve triple-checked each of these connectors&#8230;<\/p><\/div>\n<p>Not pretty.\u00a0 It\u2019ll look better soldered into a PCB, I promise.<\/p>\n<p>I put some push-buttons on the setup which aren\u2019t in the diagram, to enable manual testing.\u00a0 These are on pins 2, 3, and 4.<\/p>\n<p>If you\u2019re going to code this yourself, have at it!\u00a0 Just remember to comment liberally and informatively, always focusing on the \u2018why\u2019 a thing is there (readers will be able to figure out what is there just by looking at the code).<\/p>\n<p>I\u2019m probably going to end up packaging and selling this thing as a lighting harness for the ship, so I hope you\u2019ll forgive me if I hang onto the code I\u2019ve written.<\/p>\n<p>Next time I do a write-up I will have run through a complete test of this wiring harness and moved it onto a PCB.\u00a0 I might do a video of that part as well, not sure yet.\u00a0 In any case, thanks for stopping in again and I\u2019m looking forward to passing on more news as I get back to work on the Big Lady.<\/p>\n<p><a href=\"http:\/\/borkedcode.com\/wp\/?p=1402\">USS Enterprise \u2013 Build Log Part\u00a015<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Build Log: \u00a0Part 16 Well, hi! First off, I feel an apology is necessary here \u2013 I haven\u2019t updated my log in a LONG time, and I should have.\u00a0 I\u2019m sorry.\u00a0 Since last we spoke, I\u2019ve had a move across &hellip; <a href=\"https:\/\/borkedcode.com\/wp\/?p=1516\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[58,57,73,1],"tags":[64,74,76,75],"class_list":["post-1516","post","type-post","status-publish","format-standard","hentry","category-build-log","category-model-kits","category-sci-fi","category-uncategorized","tag-model-kit","tag-polar-lights","tag-star-trek","tag-uss-enterprise"],"_links":{"self":[{"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1516"}],"version-history":[{"count":2,"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1516\/revisions"}],"predecessor-version":[{"id":1529,"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1516\/revisions\/1529"}],"wp:attachment":[{"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/borkedcode.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}