element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino Projects
  • Products
  • Arduino
  • Arduino Projects
  • More
  • Cancel
Arduino Projects
Blog Old Battleship Phone With Arduino UNO
  • Blog
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Steve524
  • Date Created: 22 May 2024 3:28 PM Date Created
  • Views 759 views
  • Likes 7 likes
  • Comments 6 comments
  • project
  • uno
  • arduino
  • arduino projects
Related
Recommended

Old Battleship Phone With Arduino UNO

Steve524
Steve524
22 May 2024
Old Battleship Phone With Arduino UNO

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 the MP3 module to select audio from one of the 12 positions. The audio I selected for each of the 12 positions is a different SIT tone (Situation Information Tone) used by the landline phones, you may recall what it is with the tones you hear when you mis-dial or no one is at the phone number you called. Two of the 12 samples are attached below.

imageimageimageimageimageimageimageimageimage

Fullscreen Old_Ship_Phone.txt Download
                       //INPUTS
const int ssp01 = 21;  //selector switch position 1
const int ssp02 = 22;  //selector switch position 2
const int ssp03 = 23;  //selector switch position 3
const int ssp04 = 24;  //selector switch position 4
const int ssp05 = 25;  //selector switch position 5
const int ssp06 = 26;  //selector switch position 6
const int ssp07 = 27;  //selector switch position 7
const int ssp08 = 28;  //selector switch position 8
const int ssp09 = 29;  //selector switch position 9
const int ssp10 = 30;  //selector switch position 10
const int ssp11 = 31;  //selector switch position 11
const int ssp12 = 32;  //selector switch position 12
const int LED33 = 33;  //Busy LED 33

                   //INPUT VALs
int ssp01val = 0;  //selector switch position 1   val
int ssp02val = 0;  //selector switch position 2   val
int ssp03val = 0;  //selector switch position 3   val
int ssp04val = 0;  //selector switch position 4   val   
int ssp05val = 0;  //selector switch position 5   val
int ssp06val = 0;  //selector switch position 6   val
int ssp07val = 0;  //selector switch position 7   val
int ssp08val = 0;  //selector switch position 8   val
int ssp09val = 0;  //selector switch position 9   val
int ssp10val = 0;  //selector switch position 10  val
int ssp11val = 0;  //selector switch position 11  val
int ssp12val = 0;  //selector switch position 12  val
int LED33val = 0;  //Busy LED 33    val

                       //OUTPUTS
const int op01 = 2;    //output pin d2
const int op02 = 3;    //output pin d3
const int op03 = 4;    //output pin d4
const int op04 = 5;    //output pin d5
const int op05 = 6;    //output pin d6
const int op06 = 7;    //output pin d7
const int op07 = 8;    //output pin d8
const int op08 = 9;    //output pin d9
const int op09 = 13;   //output pin d13 Busy LED 13

                //OUTPUT VALs
int op01val;    //output pin d2    val
int op02val;    //output pin d3    val
int op03val;    //output pin d4    val
int op04val;    //output pin d5    val
int op05val;    //output pin d6    val
int op06val;    //output pin d7    val
int op07val;    //output pin d8    val
int op08val;    //output pin d9    val
int op09val;    //output pin d13   val Busy LED 13

void setup()
 {
Serial.begin(9600);
pinMode(ssp01,INPUT_PULLUP);  //21 Input pins
pinMode(ssp02,INPUT_PULLUP);  //22
pinMode(ssp03,INPUT_PULLUP);  //23
pinMode(ssp04,INPUT_PULLUP);  //24
pinMode(ssp05,INPUT_PULLUP);  //25
pinMode(ssp06,INPUT_PULLUP);  //26
pinMode(ssp07,INPUT_PULLUP);  //27
pinMode(ssp08,INPUT_PULLUP);  //28
pinMode(ssp09,INPUT_PULLUP);  //29
pinMode(ssp10,INPUT_PULLUP);  //30
pinMode(ssp11,INPUT_PULLUP);  //31
pinMode(ssp12,INPUT_PULLUP);  //32
pinMode(LED33,INPUT);         //33 LED Busy pin input value 

pinMode(op01,OUTPUT);
pinMode(op02,OUTPUT);
pinMode(op03,OUTPUT);
pinMode(op04,OUTPUT);
pinMode(op05,OUTPUT);
pinMode(op06,OUTPUT);
pinMode(op07,OUTPUT);
pinMode(op08,OUTPUT);
pinMode(op09,OUTPUT);
  }

void loop() {

    op01val = digitalRead(op01);  
    op02val = digitalRead(op02);
    op03val = digitalRead(op03);
    op04val = digitalRead(op04);
    op05val = digitalRead(op05);
    op06val = digitalRead(op06);
    op07val = digitalRead(op07);
    op08val = digitalRead(op08);
    op09val = digitalRead(op09);
        
    Serial.print("op01 ");     // Serial.print output stuff
    Serial.print(op01val);
    Serial.print(" ");
    Serial.print("op02 ");
    Serial.print(op02val);
    Serial.print(" ");
    Serial.print("op03 ");
    Serial.print(op03val);
    Serial.print(" ");
    Serial.print("op04 ");
    Serial.print(op04val);
    Serial.print(" ");
    Serial.print("op05 ");
    Serial.print(op05val);
    Serial.print(" ");
    Serial.print("op06 ");
    Serial.print(op06val);
    Serial.print(" ");
    Serial.print("op07 ");
    Serial.print(op07val);
    Serial.print(" ");
    Serial.print("op08 ");
    Serial.print(op08val);
    Serial.print(" ");
    Serial.print("op09LED ");
    Serial.println(op09val);   
    
  ssp01val = digitalRead(ssp01);        
  if(ssp01val == LOW)           // 11111110 (Message1 00001.mp3)
  {
    digitalWrite(op01, LOW);    // 0 
    digitalWrite(op02, HIGH);   // 1
    digitalWrite(op03, HIGH);   // 1
    digitalWrite(op04, HIGH);   // 1
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp02val = digitalRead(ssp02);
  if(ssp02val == LOW)           // 11111101 (Message2 00002.mp3)
  {
    digitalWrite(op01, HIGH);   // 1 
    digitalWrite(op02, LOW);    // 0
    digitalWrite(op03, HIGH);   // 1
    digitalWrite(op04, HIGH);   // 1
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }  
  ssp03val = digitalRead(ssp03);
  if(ssp03val == LOW)           // 11111100 (Message1 00003.mp3)
  {
    digitalWrite(op01, LOW);    // 0 
    digitalWrite(op02, LOW);    // 0
    digitalWrite(op03, HIGH);   // 1
    digitalWrite(op04, HIGH);   // 1
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp04val = digitalRead(ssp04);
  if(ssp04val == LOW)           // 11111011 (Message1 00004.mp3)
  {
    digitalWrite(op01, HIGH);   // 1 
    digitalWrite(op02, HIGH);   // 1
    digitalWrite(op03, LOW);    // 0
    digitalWrite(op04, HIGH);   // 1
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp05val = digitalRead(ssp05);
  if(ssp05val == LOW)           // 11111010 (Message1 00005.mp3)
  {
    digitalWrite(op01, LOW);    // 0 
    digitalWrite(op02, HIGH);   // 1
    digitalWrite(op03, LOW);    // 0
    digitalWrite(op04, HIGH);   // 1
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp06val = digitalRead(ssp06);
  if(ssp06val == LOW)           // 11111001 (Message1 00006.mp3)
  {
    digitalWrite(op01, HIGH);   // 1 
    digitalWrite(op02, LOW);    // 0
    digitalWrite(op03, LOW);    // 0
    digitalWrite(op04, HIGH);   // 1
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp07val = digitalRead(ssp07);
  if(ssp07val == LOW)           // 11111000 (Message1 00007.mp3)
  {
    digitalWrite(op01, LOW);    // 0 
    digitalWrite(op02, LOW);    // 0
    digitalWrite(op03, LOW);    // 0
    digitalWrite(op04, HIGH);   // 1
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp08val = digitalRead(ssp08);
  if(ssp08val == LOW)           // 11110111 (Message1 00008.mp3)
  {
    digitalWrite(op01, HIGH);   // 1 
    digitalWrite(op02, HIGH);   // 1
    digitalWrite(op03, HIGH);   // 1
    digitalWrite(op04, LOW);    // 0
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp09val = digitalRead(ssp09);
  if(ssp09val == LOW)           // 11110110 (Message1 00009.mp3)
  {
    digitalWrite(op01, LOW);    // 0 
    digitalWrite(op02, HIGH);   // 1
    digitalWrite(op03, HIGH);   // 1
    digitalWrite(op04, LOW);    // 0
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp10val = digitalRead(ssp10);
  if(ssp10val == LOW)           // 11110101 (Message1 00010.mp3)
  {
    digitalWrite(op01, HIGH);   // 1 
    digitalWrite(op02, LOW);    // 0
    digitalWrite(op03, HIGH);   // 1
    digitalWrite(op04, LOW);    // 0
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp11val = digitalRead(ssp11);
  if(ssp11val == LOW)           // 11110100 (Message1 00011.mp3)
  {
    digitalWrite(op01, LOW);    // 0 
    digitalWrite(op02, LOW);    // 0
    digitalWrite(op03, HIGH);   // 1
    digitalWrite(op04, LOW);    // 0
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
  ssp12val = digitalRead(ssp12);
  if(ssp12val == LOW)           // 11110011 (Message1 00012.mp3)
  {
    digitalWrite(op01, HIGH);   // 1 
    digitalWrite(op02, HIGH);   // 1
    digitalWrite(op03, LOW);    // 0
    digitalWrite(op04, LOW);    // 0
    digitalWrite(op05, HIGH);   // 1
    digitalWrite(op06, HIGH);   // 1
    digitalWrite(op07, HIGH);   // 1
    digitalWrite(op08, HIGH);   // 1
  }
   
   LED33val = digitalRead(LED33);  // Read the state of the LED Busy value
  
   if(LED33val == LOW)             // Busy LED pin 33 INPUT (LOW = Playing)
  {
   digitalWrite(op09, HIGH);       // Busy LED pin 13 OUTPUT (LED = On)
  }
   else if(LED33val == HIGH)       // Busy LED pin 33 INPUT (HIGH = Stopped)
  {
   digitalWrite(op09, LOW);        // Busy LED pin 13 OUTPUT (LED = Off)
  }
} 
 
Play this audio clipPlay this audio clip

  • Sign in to reply
  • DAB
    DAB over 1 year ago

    Very cool project.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 1 year ago

    Nice score. Nothing like solid and authentic hardware to give a project great cachet. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • javagoza
    javagoza over 1 year ago in reply to shabaz

    You put all your effort into putting everything together with arrays and loops and then the compiler comes along and makes you a loop unrolling. I'm just kidding, I'm also an advocate of readable and maintainable code.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Steve524
    Steve524 over 1 year ago in reply to shabaz

    I did not use arrays in that particular setting but I use arrays in other projects. This was just quick and dirty to put together to make it work, although I do like what you have posted with the alternative code thank you very much.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 1 year ago

    Very interesting project, it's a great idea.

    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.

    That'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.

    I've had a go at doing it, I have not tested since I don't have your setup. It is definitely worth looking through though, because you'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'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.

    // ****************************************************
    // ************* Battleship Phone *********************
    // ****************************************************
    
    // ******************* defines ************************
    #define NUM_INPUTS 13
    #define NUM_OUTPUTS 9
    #define BUSY_IN_PIN 33
    #define LED_OUT_PIN 13
    
    // ****************** GPIO pins *********************
    // Input pins (selector switches and Busy input)
    const int input_pin[NUM_INPUTS] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, BUSY_IN_PIN};
    int input_value[NUM_INPUTS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    // Output pins (MP3 select pins, and output LED)
    const int output_pin[NUM_OUTPUTS] = {2, 3, 4, 5, 6, 7, 8, 9, LED_OUT_PIN};
    int output_value[NUM_OUTPUTS];
    
    // **************** setup function ******************
    void setup()
    {
      int i;
      Serial.begin(9600);
      // set the pin modes for all inputs and outputs accordingly
      for (i=0; i<NUM_INPUTS; i++) {
        pinMode(input_pin[i], INPUT_PULLUP);
      }
      for (i=0; i<NUM_OUTPUTS; i++) {
        pinMode(output_pin[i], OUTPUT);
      }
    }
    
    // *************** mp3_select ***********************
    // mp3_select is used to set eight output pins
    // example: mp3_select(3) will set the pins to the inverse of 
    // binary 3 (0000 0011) i.e. 1111 1100. 
    void mp3_select(char track) {
        for (int i = 0; i < 8; i++) { 
            if (track & (1 << i)) {
                // set the pin to low
                digitalWrite(output_pin[i], LOW);
            } else {
                // set the pin to high
                digitalWrite(output_pin[i], HIGH);
            }
        }
    }
    
    // *************** loop function *********************
    void loop() {
      int i;
      char text[16];
      char busy_status;
    
      // read all the output pins (not sure why, just to print status?)
      for (i=0; i<NUM_OUTPUTS; i++) {
        output_value[i] = digitalRead(output_pin[i]);
      }
      for (i=0; i<NUM_OUTPUTS; i++) {
        sprintf(text, "op%d: %d ", i+1, output_value[i]);
        Serial.print(text);
      }
      
      // read all the selector switch inputs, and play the relevant MP3 file
      for (i=0; i<NUM_INPUTS-1; i++) {
        input_value[i] = digitalRead(input_pin[i]);
        if (input_value[i] == LOW) {
          mp3_select(i+1);
          // should handle debounce here if desired.
          // also, should have a break statement here, but I kept the original logic
        }
      }
    
      // update the LED to indicate the playout status
      busy_status = digitalRead(BUSY_IN_PIN);
      if (busy_status==LOW) { // playing
        digitalWrite(LED_OUT_PIN, HIGH);
      } else { // stopped
        digitalWrite(LED_OUT_PIN, LOW);
      }
      
    } 
    

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube