Ship model controlled using Arduino

I could see where it'd be advantageous to have numerous ATmega/driver boards.

You have one master that receives the RF command and acknowledges back to shore. It then relays the 1 of 128 commands out to each board. Wiring from master to slaves then just consists of power, ground, and Tx (and Rx if you want an ack message back).

Each board could then be programmed to run a function continously (lights for instance, run this flashing sequence until another is commanded) or to run a set of short term functions, then wait for another (raise the anchor, lower the anchor, turn left for a second or until a heading is reached, etc).

if (Serial.available()>0{ // is a message in? commandCode =; } switch (commandCode){ case 0: // code for do nothing break; case 1: // code for first command // if command is for run once & then wait, add this: commandCode = 0; // if command is to repeat until next message, then leave commandCode at same value // if another action is to occur after this one, can set commandCode to a new value to run commandCode = 127; // for example break; : : case 127: // code break; } // end switch

Thanks for the advice.

I copied the code to the Arduino software for later use. At this point I think I'll need to learn to program Arduino a little more, as I like to be able to work the codes out myself too. This is partially because I like working with electronics, and partially because I would like to be able to program the next model (which is to have even more functions) pretty much all by myself.

Greetings Josse

Sounds good. Get a feature or two coded up, let us know how it goes.

Remember my little Kormoran boat and the little code for the random leds? It came from this piece of code we wrote. It combines a letter and a number code (0-255) for the different function groups. I included the Led/test versioncode. One can modify it easily for more groups and different functions. Just type L (or l) and a number for different led/function combinations. I (or i) for reset to default values. I used pin 2-9 since I like to keep the 0 and 1 pin for communication. I replaced the original Dutch comments and replaced them for this international forum.



// Use this code, make it better and share it.
// C.M. Bianchi (rip) and D.D. van Dijk

int pinNumber; int pinValue;
int ledPin1 = 2; int ledPin2 = 3; int ledPin3 = 4; int ledPin4 = 5; 
int ledPin5 = 6; int ledPin6 = 7; int ledPin7 = 8; int ledPin8 = 9;
char buffer[64]; char msg[140] = "";

void defaultvalues(){
 digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); 
 digitalWrite(ledPin3, LOW); digitalWrite(ledPin4, LOW); 
 digitalWrite(ledPin5, LOW); digitalWrite(ledPin6, LOW); 
 digitalWrite(ledPin7, LOW); digitalWrite(ledPin8, LOW); 

void setup() {
  Serial.begin(9600); Serial.flush();
  pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT); pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT); pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT); pinMode(ledPin8, OUTPUT);

void loop() {

  if (Serial.available() > 0) { 
    int index=0; 
    delay(10); // let the buffer fill up 
    int numChar = Serial.available(); 
    if (numChar>64) { 
    while (numChar--) { 
      buffer[index++] =; 
void splitString(char* data) { 
  Serial.print("Data entered: "); 
  char* parameter; 
  parameter = strtok (data, " ,"); 
  while (parameter != NULL) { 
    parameter = strtok (NULL, " ,"); 
  // Clear the text and serial buffers 
  for (int x=0; x<64; x++) { 

// initialize to default settings with typing I or i
void setLED(char* data) { 
if ((data[0] == 'i') || (data[0] == 'I')) {
if ((data[0] == 'l') || (data[0] == 'L')) { 
  int ledcode = strtol(data+1, NULL, 10);
////////////////////////////////// PIN 8 ///////////////////////////////
   if (ledcode >= 128) {
    digitalWrite(ledPin8, HIGH);
    Serial.println("Pin8 = on");
    ledcode = (ledcode - 128); 
   else {digitalWrite(ledPin8, LOW);}
////////////////////////////////// PIN 7 ///////////////////////////////
   if (ledcode >= 64) {
    digitalWrite(ledPin7, HIGH);
    Serial.println("Pin7 = on"); 
    ledcode = (ledcode - 64);
   else {digitalWrite(ledPin7, LOW);}
////////////////////////////////// PIN 6 ///////////////////////////////
   if (ledcode >= 32) {
    digitalWrite(ledPin6, HIGH);
    Serial.println("Pin6 = on");
    ledcode = (ledcode - 32); 
   else {digitalWrite(ledPin6, LOW);}   
////////////////////////////////// PIN 5 ///////////////////////////////
   if (ledcode >= 16) {
    digitalWrite(ledPin5, HIGH);
    Serial.println("Pin5 = on");
    ledcode = (ledcode - 16); 
   else {digitalWrite(ledPin5, LOW);}   
////////////////////////////////// PIN 4 ///////////////////////////////
   if (ledcode >= 8) {
    digitalWrite(ledPin4, HIGH);
    Serial.println("Pin4 = on"); 
    ledcode = (ledcode - 8);
   else {digitalWrite(ledPin4, LOW);}   
////////////////////////////////// PIN 3 ///////////////////////////////
   if (ledcode >= 4) {
    digitalWrite(ledPin3, HIGH);
    Serial.println("Pin3 = on");
    ledcode = (ledcode - 4); 
   else {digitalWrite(ledPin3, LOW);}  
////////////////////////////////// PIN 2 ///////////////////////////////
   if (ledcode >= 2) {
    digitalWrite(ledPin2, HIGH);
    Serial.println("Pin2 = on");
    ledcode = (ledcode - 2); 
   else {digitalWrite(ledPin2, LOW);}   
////////////////////////////////// PIN 1 ///////////////////////////////
   if (ledcode >= 1) {
    digitalWrite(ledPin1, HIGH);
    Serial.println("Pin1 = on");
    ledcode = (ledcode - 1); 
   else {digitalWrite(ledPin1, LOW);}   

There's a lot to be said for using several arduinos as slaves. Being able to operate cranes with one and not having to worry about light-settings since other ones take care of that certainly has its advantages. Using 1 arduino every 18 lights does seem serious overkill to me though, one 32KB arduino probably could control all light related functions and more.

You do have a lot of different peripherals on your boat, several won't need very much processing power or programming space. Personally I would look at costs. If I was going to use several arduinos as slaves, I'd probably build them and use the cheaper 8KB atmega8-controllers where possible instead of using standard 32KB unos, nanos, minis or larger megas.

Having enough processing speed and programming-space available on 32-256 KB arduinos to support a number of different functions, I'd try to use those as efficient as possible. Controlling a small number of pins while being a sleep most of the time and running a small program, would not be ideal IMO. Advantage of Shift-registers in that respect is that they hardly cost anything and give you close to as much IO-pins as you need. Disadvantage, having to run several routines at the same time on the same controller and making sure one routine doesn't get in the way of the other.

Just my thoughts. I used 1 Arduino Nano (6 pins for PWM and 2 for i2C) and a bunch of portexpanders for my boat. Just send an adress and number by the i2c line and let the expanders worry about the functions.


Hello Simpson,

Thanks for the advice. Although I'm not quite rich, I'd prefer to do things as good as possible. When taking into account that the other option would be a transmitter costing as much as I calculated to be paying for the Arduino's, and then I'd need about 8 16-channel decoders, each costing as much as 2 Arduino Mega's, so I already do save quite some money. On the other hand, more processing power then needed is useless. I apparently haven't been checking the available Arduino's out properly.

There is 1 thing I need to know, but which I haven't been able to find on the internet: what are the dimensions of the different Arduino's? I already own a UNO, of which I off course can measure the dimensions myself. The reason I want to know this is that I want to prepare some space for them, but even though this boat isn't really small at 1,76m length, every bit of interior space should be used efficiently, even if it would only be to make sure I can get to parts that got damaged or broken. There also is the need to be able to place ballast in the hull, spread out over the full length of the vessel, otherwise she'll hardly get to her waterline.

If I read the posts I start to get a feeling that it might be useful to make a detailed list of which functions will be placed where. I get the feeling that there might be some misunderstanding about the position of various functions. Here is the list:

Superstructure: Lights in the main mast 20 Anchorrlight 1 Prepare to sail 1 Searchlights 6 Flood lights 2 Panama-steering lights 3 Interior lights 1 Lights helideck 2 Firemonitors 6

Bow: Bow thruster 1 Davits 13 Lifeboats 12 A-frames 4 ROV's 20 Anchors 6 Fire fighting equipment helideck 1 Searchlight bow 3 Crane on dive-area 5 Fog horn 1 General alarm 1

Midships: Communication with transmitter Spreading the command's Determining position for DP Transmitting video footage (possibly using other means then Arduino)

Stern: Throttle main engines 1 Rudder 1 Main crane 5 Secondary crane 4 Tautwire 2 Mooring 1

I hope this will make clear how the functions could best be divided. Controlling the crane on the dive-area and the davits for the RHIB and the hyperbaric lifeboat could be moved to the midship computer, as that computer is much closer then the bow computer. The reason it hasn't been set-up this way is that I wanted to have the midship computer focus on communications.

Greetings Josse