{"id":761,"date":"2016-07-18T09:48:52","date_gmt":"2016-07-18T08:48:52","guid":{"rendered":"https:\/\/howiem.org\/wordpress\/?p=761"},"modified":"2016-07-18T09:48:52","modified_gmt":"2016-07-18T08:48:52","slug":"reverse-swear-box","status":"publish","type":"post","link":"https:\/\/howiem.org\/wordpress\/2016\/07\/18\/reverse-swear-box\/","title":{"rendered":"Reverse swear box"},"content":{"rendered":"<p>Most swear boxes work the wrong way round: you say something naughty, then you have to put money in the box as penance. This is the opposite &#8211; press the button and this device generates a random swear word for you to use in conversation at your leisure. Technology, eh.<\/p>\n<p>It&#8217;s not a new idea: a few years ago I came across this beautiful &#8220;Four Letter Word&#8221; clock made with delicious old fashioned nixie tubes:<\/p>\n<p><a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/flw1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-18\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/flw1-720x386.jpg\" alt=\"flw1\" width=\"720\" height=\"386\" \/><\/a><\/p>\n<p>Designed and built by Jeff Thomas, Peter Hand, and Juergen Grau. More information <a title=\"GPS Four Letter Word display\" href=\"http:\/\/www.amug.org\/~jthomas\/gpsflw.html\">here<\/a>.<\/p>\n<p>I wanted to make something quick and simple as a birthday present for a friend, and I had four little LED starburst displays sitting in a box, so some sort of random word dispenser seemed like a good idea. Designed a quick circuit in Eagle:<\/p>\n<p><a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-20-at-07.36.07.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-26\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-20-at-07.36.07-720x340.png\" alt=\"Screen Shot 2014-05-20 at 07.36.07\" width=\"720\" height=\"340\" \/><\/a><\/p>\n<p>Download schematic and layout: <a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/FourLetterWord.zip\">FourLetterWord<\/a><\/p>\n<p>The schematic in Eagle is pretty messy and tangled. I often find that if I&#8217;ve got loads of connections to make to a microcontroller, it&#8217;s not until I&#8217;m laying out the board design that I can see the way things should be connected.<\/p>\n<p>This is the perfect example: I&#8217;m connecting two identical starburst displays to the microcontroller in a multiplexed fashion. In an ideal world you&#8217;d connect the anodes of the displays together, segment A to segment A, seg B to seg B and so on, leaving just the cathodes of each digit to be connected separately. This makes the software a little simpler &#8211; pin D3 (say) on the microcontroller controls the same segment on all the digits:<br \/>\n<a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-20-at-08.06.23.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-28\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-20-at-08.06.23.png\" alt=\"Screen Shot 2014-05-20 at 08.06.23\" width=\"456\" height=\"419\" \/><\/a><\/p>\n<p>On a single sided PCB, though, routing the connections like that gets really tricky &#8211; you end up with loads of connections that have to jump over others so they end up on the right pins.<\/p>\n<p>The alternative is to design the circuit so it&#8217;s easy to route (even if that means segment A on one display is connected to segment F on the other etc) and then sort it all out in the software.<\/p>\n<p><a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-20-at-08.06.36.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-29\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-20-at-08.06.36.png\" alt=\"Screen Shot 2014-05-20 at 08.06.36\" width=\"459\" height=\"419\" \/><\/a><\/p>\n<p>Hence the relatively neat looking PCB design:<\/p>\n<p><a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-20-at-07.36.25.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-27\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-20-at-07.36.25-720x488.png\" alt=\"Screen Shot 2014-05-20 at 07.36.25\" width=\"720\" height=\"488\" \/><\/a><\/p>\n<p>Note that there&#8217;s an error in the design \/ layout &#8211; I didn&#8217;t realise until too late that two of the microcontroller pins I wanted to use (A6 and A7) wouldn&#8217;t work as digital pins, so I had to use some wires to connect them to some free pins on the other side of the controller. Live and learn.<\/p>\n<p><a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0219.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-22\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0219-720x480.jpg\" alt=\"HFLW-IMG_0219\" width=\"720\" height=\"480\" \/><\/a><\/p>\n<p>With the PCB milled out and populated, I hacked a rectangular hole out of a random wooden box I had knocking about, and stuck a switch and a button on it, and squished a bit of foam and a CR123A battery holder in.<\/p>\n<p><a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0223.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-23\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0223-720x480.jpg\" alt=\"HFLW-IMG_0223\" width=\"720\" height=\"480\" \/><\/a><\/p>\n<p>CR123A batteries are great for this sort of project &#8211; they only run at 3 volts, but that&#8217;s enough to drive LED displays without needing to add current limiting resistors. Helps that the display is multiplexed, too; though it looks like all the displays are lit up simultaneously, they&#8217;re actually taking turns, one digit at a time. Stops the LEDs from burning out &#8211; at most they&#8217;re on for 25% of the time.<\/p>\n<p>The software&#8217;s pretty simple &#8211; there&#8217;s a list of about 45 swear words chosen at random. Proper randomness isn&#8217;t easy for a microcontroller (or a computer) to do on its own, so I measure how long the user has pressed the button, in microseconds, and use that value to help choose a word.<\/p>\n<p><a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0227.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-24\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0227-720x480.jpg\" alt=\"HFLW-IMG_0227\" width=\"720\" height=\"480\" \/><\/a><\/p>\n<p>Press the button and an animation sweeps across the display, with each letter of the word coming up one at a time like a fruit machine.<\/p>\n<p><a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0216.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-20\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0216-720x480.jpg\" alt=\"HFLW-IMG_0216\" width=\"720\" height=\"480\" \/><\/a><\/p>\n<p><a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0233.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-25\" src=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/HFLW-IMG_0233-720x480.jpg\" alt=\"HFLW-IMG_0233\" width=\"720\" height=\"480\" \/><\/a><\/p>\n<p>Download software: <a href=\"https:\/\/howiem.org\/projects\/wp-content\/uploads\/2014\/05\/FourLetterWord-Arduino-code.zip\">FourLetterWord-Arduino code<\/a><\/p>\n<p>It&#8217;s surprisingly hard to come up with lots of 4-lettered obscenities, so there are some strange ones in there. My favourite is &#8220;MILK&#8221;&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most swear boxes work the wrong way round: you say something naughty, then you have to put money in the box as penance. This is the opposite &#8211; press the&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":{"0":"post-761","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-electronics-and-hackery"},"_links":{"self":[{"href":"https:\/\/howiem.org\/wordpress\/wp-json\/wp\/v2\/posts\/761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/howiem.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/howiem.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/howiem.org\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/howiem.org\/wordpress\/wp-json\/wp\/v2\/comments?post=761"}],"version-history":[{"count":0,"href":"https:\/\/howiem.org\/wordpress\/wp-json\/wp\/v2\/posts\/761\/revisions"}],"wp:attachment":[{"href":"https:\/\/howiem.org\/wordpress\/wp-json\/wp\/v2\/media?parent=761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/howiem.org\/wordpress\/wp-json\/wp\/v2\/categories?post=761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/howiem.org\/wordpress\/wp-json\/wp\/v2\/tags?post=761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}