<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Old Battleship Phone With Arduino UNO</title><link>/products/arduino/arduino-projects/b/blog/posts/old-battle-ship-phone-with-arduino-uno</link><description>This is an old restoration project of an old battleship phone which I retrofitted with an Arduino UNO and a BCD MP3 player module. The front of the phone has a selector switch which I tied to the inputs of the Arduino which then sends a BCD code to t</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Old Battleship Phone With Arduino UNO</title><link>https://community.element14.com/products/arduino/arduino-projects/b/blog/posts/old-battle-ship-phone-with-arduino-uno</link><pubDate>Thu, 23 May 2024 20:10:43 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:6590d9a5-48c8-4975-954d-060bb31d0304</guid><dc:creator>DAB</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Very cool project.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=27992&amp;AppID=149&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Old Battleship Phone With Arduino UNO</title><link>https://community.element14.com/products/arduino/arduino-projects/b/blog/posts/old-battle-ship-phone-with-arduino-uno</link><pubDate>Wed, 22 May 2024 20:48:47 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:6590d9a5-48c8-4975-954d-060bb31d0304</guid><dc:creator>dougw</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Nice score. Nothing like solid and authentic hardware to give a project great cachet.&amp;nbsp;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=27992&amp;AppID=149&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Old Battleship Phone With Arduino UNO</title><link>https://community.element14.com/products/arduino/arduino-projects/b/blog/posts/old-battle-ship-phone-with-arduino-uno</link><pubDate>Wed, 22 May 2024 17:03:06 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:6590d9a5-48c8-4975-954d-060bb31d0304</guid><dc:creator>shabaz</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;Very interesting project, it&amp;#39;s a great idea.&lt;/p&gt;
&lt;p&gt;I had to comment, not to detract from the project or the current code, but just as a suggestion, that the code can be significantly reduced (to less than a third), by using arrays.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s often worth doing, because that means there is a lot less to debug, and can be quickly adjusted if (say) there were more or less selector switches and so on.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve had a go at doing it, I have not tested since I don&amp;#39;t have your setup. It is definitely worth looking through though, because you&amp;#39;ll see the differences compared to your code which you already know, and the comparison can often be a simple way to quickly pick up on programming methods/styles (not saying mine is perfect, it isn&amp;#39;t). I would have done a few more things differently, a few things are redundant but I kept it all in a near-identical way so that it is easy for you to see the differences.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:60801f9e-f079-4817-a1d8-bf0987a830af:type=c_cpp&amp;text=%2F%2F%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0D%0A%2F%2F%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20Battleship%20Phone%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0D%0A%2F%2F%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0D%0A%0D%0A%2F%2F%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20defines%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0D%0A%23define%20NUM_INPUTS%2013%0D%0A%23define%20NUM_OUTPUTS%209%0D%0A%23define%20BUSY_IN_PIN%2033%0D%0A%23define%20LED_OUT_PIN%2013%0D%0A%0D%0A%2F%2F%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20GPIO%20pins%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0D%0A%2F%2F%20Input%20pins%20%28selector%20switches%20and%20Busy%20input%29%0D%0Aconst%20int%20input_pin%5BNUM_INPUTS%5D%20%3D%20%7B21%2C%2022%2C%2023%2C%2024%2C%2025%2C%2026%2C%2027%2C%2028%2C%2029%2C%2030%2C%2031%2C%2032%2C%20BUSY_IN_PIN%7D%3B%0D%0Aint%20input_value%5BNUM_INPUTS%5D%20%3D%20%7B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%7D%3B%0D%0A%2F%2F%20Output%20pins%20%28MP3%20select%20pins%2C%20and%20output%20LED%29%0D%0Aconst%20int%20output_pin%5BNUM_OUTPUTS%5D%20%3D%20%7B2%2C%203%2C%204%2C%205%2C%206%2C%207%2C%208%2C%209%2C%20LED_OUT_PIN%7D%3B%0D%0Aint%20output_value%5BNUM_OUTPUTS%5D%3B%0D%0A%0D%0A%2F%2F%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20setup%20function%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0D%0Avoid%20setup%28%29%0D%0A%7B%0D%0A%20%20int%20i%3B%0D%0A%20%20Serial.begin%289600%29%3B%0D%0A%20%20%2F%2F%20set%20the%20pin%20modes%20for%20all%20inputs%20and%20outputs%20accordingly%0D%0A%20%20for%20%28i%3D0%3B%20i%3CNUM_INPUTS%3B%20i%2B%2B%29%20%7B%0D%0A%20%20%20%20pinMode%28input_pin%5Bi%5D%2C%20INPUT_PULLUP%29%3B%0D%0A%20%20%7D%0D%0A%20%20for%20%28i%3D0%3B%20i%3CNUM_OUTPUTS%3B%20i%2B%2B%29%20%7B%0D%0A%20%20%20%20pinMode%28output_pin%5Bi%5D%2C%20OUTPUT%29%3B%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0A%2F%2F%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20mp3_select%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0D%0A%2F%2F%20mp3_select%20is%20used%20to%20set%20eight%20output%20pins%0D%0A%2F%2F%20example%3A%20mp3_select%283%29%20will%20set%20the%20pins%20to%20the%20inverse%20of%20%0D%0A%2F%2F%20binary%203%20%280000%200011%29%20i.e.%201111%201100.%20%0D%0Avoid%20mp3_select%28char%20track%29%20%7B%0D%0A%20%20%20%20for%20%28int%20i%20%3D%200%3B%20i%20%3C%208%3B%20i%2B%2B%29%20%7B%20%0D%0A%20%20%20%20%20%20%20%20if%20%28track%20%26%20%281%20%3C%3C%20i%29%29%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20set%20the%20pin%20to%20low%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20digitalWrite%28output_pin%5Bi%5D%2C%20LOW%29%3B%0D%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20set%20the%20pin%20to%20high%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20digitalWrite%28output_pin%5Bi%5D%2C%20HIGH%29%3B%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0A%2F%2F%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20loop%20function%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0D%0Avoid%20loop%28%29%20%7B%0D%0A%20%20int%20i%3B%0D%0A%20%20char%20text%5B16%5D%3B%0D%0A%20%20char%20busy_status%3B%0D%0A%0D%0A%20%20%2F%2F%20read%20all%20the%20output%20pins%20%28not%20sure%20why%2C%20just%20to%20print%20status%3F%29%0D%0A%20%20for%20%28i%3D0%3B%20i%3CNUM_OUTPUTS%3B%20i%2B%2B%29%20%7B%0D%0A%20%20%20%20output_value%5Bi%5D%20%3D%20digitalRead%28output_pin%5Bi%5D%29%3B%0D%0A%20%20%7D%0D%0A%20%20for%20%28i%3D0%3B%20i%3CNUM_OUTPUTS%3B%20i%2B%2B%29%20%7B%0D%0A%20%20%20%20sprintf%28text%2C%20%22op%25d%3A%20%25d%20%22%2C%20i%2B1%2C%20output_value%5Bi%5D%29%3B%0D%0A%20%20%20%20Serial.print%28text%29%3B%0D%0A%20%20%7D%0D%0A%20%20%0D%0A%20%20%2F%2F%20read%20all%20the%20selector%20switch%20inputs%2C%20and%20play%20the%20relevant%20MP3%20file%0D%0A%20%20for%20%28i%3D0%3B%20i%3CNUM_INPUTS-1%3B%20i%2B%2B%29%20%7B%0D%0A%20%20%20%20input_value%5Bi%5D%20%3D%20digitalRead%28input_pin%5Bi%5D%29%3B%0D%0A%20%20%20%20if%20%28input_value%5Bi%5D%20%3D%3D%20LOW%29%20%7B%0D%0A%20%20%20%20%20%20mp3_select%28i%2B1%29%3B%0D%0A%20%20%20%20%20%20%2F%2F%20should%20handle%20debounce%20here%20if%20desired.%0D%0A%20%20%20%20%20%20%2F%2F%20also%2C%20should%20have%20a%20break%20statement%20here%2C%20but%20I%20kept%20the%20original%20logic%0D%0A%20%20%20%20%7D%0D%0A%20%20%7D%0D%0A%0D%0A%20%20%2F%2F%20update%20the%20LED%20to%20indicate%20the%20playout%20status%0D%0A%20%20busy_status%20%3D%20digitalRead%28BUSY_IN_PIN%29%3B%0D%0A%20%20if%20%28busy_status%3D%3DLOW%29%20%7B%20%2F%2F%20playing%0D%0A%20%20%20%20digitalWrite%28LED_OUT_PIN%2C%20HIGH%29%3B%0D%0A%20%20%7D%20else%20%7B%20%2F%2F%20stopped%0D%0A%20%20%20%20digitalWrite%28LED_OUT_PIN%2C%20LOW%29%3B%0D%0A%20%20%7D%0D%0A%20%20%0D%0A%7D%20%0D%0A]&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=27992&amp;AppID=149&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Old Battleship Phone With Arduino UNO</title><link>https://community.element14.com/products/arduino/arduino-projects/b/blog/posts/old-battle-ship-phone-with-arduino-uno</link><pubDate>Wed, 22 May 2024 16:27:12 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:6590d9a5-48c8-4975-954d-060bb31d0304</guid><dc:creator>javagoza</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Looks great. What a fun project.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=27992&amp;AppID=149&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>