igordantas
Published

Dynamic Positioning the Vessel

This work is important, since, approaches questions related to a substitution of the current equipment and makes possible the inclusion.

AdvancedShowcase (no instructions)1,773
Dynamic Positioning the Vessel

Things used in this project

Story

Read more

Schematics

Diagrama

Code

Arduino

C#
#include <SPI.h>
// Biblioteca utilizada para comunicao 
#include <Ethernet.h>  
 
// A linha abaixo permite definir o endereo fsico (MAC ADDRESS) da... 
//placa de rede. 
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte ip[] = { 192, 168, 0, 20 };  //Define o endereo IP.
    
// Porta onde estar aberta para comunicao Internet.
EthernetServer server(80);  
 
String readString;
int Pin = 9;  //  Pino digital onde ser ligado e desligado o LED.
int Pino = 7;
int P = 5;  //  Pino digital onde ser ligado e desligado o LED.
int Pi = 11; 
int in = 6; 
int i = 8; 
void setup(){
 
pinMode(Pin, OUTPUT);  // Define o Pino 9 como sada.
pinMode(Pino, OUTPUT);
pinMode(P, OUTPUT);  // Define o Pino 5 como sada.
pinMode(Pi, OUTPUT); 
pinMode(in, OUTPUT); 
pinMode(i, OUTPUT); 
Ethernet.begin(mac, ip);  // Chama o MAC e o endereo IP da placa Ethernet.
server.begin();  //  Inicia o servidor que esta inserido junto a placa Ethernet.
}
 
void loop(){
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
 
        if (readString.length() < 100) {
          readString += c;             
        }

        if (c == '\n') {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
    
// A partir daqui comea os cdigos html.
    
client.println("<HTML>");
client.println("<BODY>");
client.println("<H1>Motores</H1>"); 
client.println("<br />");
          
client.println
("<a href=\"/motor1/on\"\">Ligar Motor</a>");
client.println("<br />");
client.println("<br />");
client.println
("<a href=\"/motor1/off\"\">Desligar Motor</a><br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");

client.println
("<a href=\"/motor2/on\"\">Ligar1 Motor</a>");
client.println("<br />");
client.println("<br />");
client.println
("<a href=\"/motor2/off\"\">Desligar1 Motor</a><br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");

client.println
("<a href=\"/ac1/on\"\">Ligar3 Motor</a>");
client.println("<br />");
client.println("<br />");
client.println
("<a href=\"/ac1/off\"\">Desligar3 Motor</a><br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");


client.println
("<a href=\"/ac2/on\"\">Ligar4 Motor</a>");
client.println("<br />");
client.println("<br />");
client.println
("<a href=\"/ac2/off\"\">Desligar4 Motor</a><br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");


client.println
("<a href=\"/a1/on\"\">Ligar5 Motor</a>");
client.println("<br />");
client.println("<br />");
client.println
("<a href=\"/a1/off\"\">Desligar5 Motor</a><br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");
client.println("<br />");

client.println
("<a href=\"/a2/on\"\">Ligar6 Motor</a>");
client.println("<br />");
client.println("<br />");
client.println
("<a href=\"/a2/off\"\">Desligar6 Motor</a><br />");


// fechar janela no final da execuo
//client.println
//("<script language='javascript'>");
//client.println
//("setTimeout( 'fechar(); ',1);");
//client.println
//("function fechar(){");
//client.println
//("if(document.all){");
//client.println
//("window.opener = window");
//client.println
//("window.close('#')");
//client.println
//("}else{");
//client.println
//("self.close();");
//client.println
//("}");
//client.println
//("}");
//client.println
//("</script>");


          
          client.println("</BODY>");
          client.println("</HTML>");
          
          delay(1);
          client.stop();
          
          if(readString.indexOf("motor1/on") > 0)
          {
            digitalWrite(Pin, HIGH);  // Liga Lampada.
          }
          else {
            if(readString.indexOf("motor1/off") > 0)
            {
              digitalWrite(Pin, LOW);  // Desliga Lampada.
            }
          }
          if(readString.indexOf("motor2/on") > 0)
          {
            digitalWrite(Pino, HIGH);  // Liga Lampada.
          }
          else {
            if(readString.indexOf("motor2/off") > 0)
            {
              digitalWrite(Pino, LOW);  // Desliga Lampada.
            }
          }
          if(readString.indexOf("ac1/on") > 0)
          {
            digitalWrite(P, HIGH);  // Liga Lampada.
          }
          else {
            if(readString.indexOf("ac1/off") > 0)
            {
              digitalWrite(P, LOW);  // Desliga Lampada.
            }
          }
          if(readString.indexOf("ac2/on") > 0)
          {
            digitalWrite(Pi, HIGH);  // Liga Lampada.
          }
          else {
            if(readString.indexOf("ac2/off") > 0)
            {
              digitalWrite(Pi, LOW);  // Desliga Lampada.
            }
          }
          if(readString.indexOf("a1/on") > 0)
          {
            digitalWrite(i, HIGH);  // Liga Lampada.
          }
          else {
            if(readString.indexOf("a1/off") > 0)
            {
              digitalWrite(i, LOW);  // Desliga Lampada.
            }
          }
          if(readString.indexOf("a2/on") > 0)
          {
            digitalWrite(in, HIGH);  // Liga Lampada.
          }
          else {
            if(readString.indexOf("a2/off") > 0)
            {
              digitalWrite(in, LOW);  // Desliga Lampada.
            }
          }
          readString="";    
        }
      }
    }
  }
}

Credits

igordantas

igordantas

1 project • 3 followers
Thanks to Automation.

Comments