Convertire sketch pde in ino

salve a tutti non sono riuscito a trovare niente a riguardo....volevo sapere è possibile?

danyelsan:
salve a tutti non sono riuscito a trovare niente a riguardo....volevo sapere è possibile?

Il .pde è la vecchia estensione usata dal IDE ante 1.x, in pratica basta che lo rinomini in .ino e sei a posto, però potrebbe essere necessario aggiustare alcune righe di codice, p.e. quella per la I2C, per renderlo compatibile con l'IDE 1.x, c'è un'opzione nel IDE che cambia in automatico l'estensione dei .pde in .ino.
Attenzione che .pde è l'estensione standard degli sketch per Processing, hanno cambiato in .ino apposta per evitare confusione, se lo sketch in oggetto è per processing questo non può essere convertito per Arduino, il linguaggio di base è totalmente diverso, non è nemmeno detto che sia possibile farne un porting visto Processing è un ambiente di lavoro per PC e non per MCU.

1 Like

nono e per arduino soltanto che io ancora usavo l'ide vecchia ....adessom mi sono aggiornato e volevo convertire i vecchi sketch per la nuova ide ...grazie per l'aiuto

un'ultima cosa...ma nella vecchia versione ide 23 e nelle versioni nuove le librerie ethernet non sono le stesse????

Con l' IDE nuovo puoi aprire anche i file .pde.
Con la versione 1.x.x il file WProgram.h é stato nominato Arduino.h. I Sketch che includono tale file devono essere modificati.

Ciao Uwe

quindi basto che apro la libreria e faccio la sostituzione? (mi sembra troppo bello) ...

Se le librerie sono fatte per IDE 1.x.x non devi modificare niente.
Ciao Uwe

danyelsan:
quindi basto che apro la libreria e faccio la sostituzione? (mi sembra troppo bello) ...

Non è detto. Dipende sempre dalla libreria, se è molto vecchia potrebbe non bastare: se l'autore la sviluppa ancora sicuramente ne avrà rilasciata una versione per l'IDE 1.0, altrimenti tocca provare

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
Arduino: 1.0.6 (Linux), Board: "Arduino Uno"
Cancello_Luci_Pulsante_MOD:22: error: no matching function for call to ‘Server::Server(int)’
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Server.h:23: note: candidates are: Server::Server()
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Server.h:23: note:                 Server::Server(const Server&)
Cancello_Luci_Pulsante_MOD:22: error: cannot declare variable ‘server’ to be of abstract type ‘Server’
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Server.h:23: note:   because the following virtual functions are pure within ‘Server’:
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Print.h:48: note: 	virtual size_t Print::write(uint8_t)
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Server.h:25: note: 	virtual void Server::begin()
Cancello_Luci_Pulsante_MOD.ino: In function ‘void loop()’:
Cancello_Luci_Pulsante_MOD:64: error: ‘class Server’ has no member named ‘available’
Cancello_Luci_Pulsante_MOD:64: error: cannot declare variable ‘client’ to be of abstract type ‘Client’
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:26: note:   because the following virtual functions are pure within ‘Client’:
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:31: note: 	virtual size_t Client::write(uint8_t)
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:32: note: 	virtual size_t Client::write(const uint8_t*, size_t)
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:33: note: 	virtual int Client::available()
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:34: note: 	virtual int Client::read()
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:36: note: 	virtual int Client::peek()
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:37: note: 	virtual void Client::flush()
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:29: note: 	virtual int Client::connect(IPAddress, uint16_t)
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:30: note: 	virtual int Client::connect(const char*, uint16_t)
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:35: note: 	virtual int Client::read(uint8_t*, size_t)
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:38: note: 	virtual void Client::stop()
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:39: note: 	virtual uint8_t Client::connected()
/home/daniele/ARDUINO/hardware/arduino/cores/arduino/Client.h:40: note: 	virtual Client::operator bool()

questo è l'errore che non riesco a eliminare

Magari se ci dici e posti lo sketch e quali librerie usi... :roll_eyes:

#include <SPI.h>
#include <Ethernet.h>
#include <mcp9700a.h>
int pinLed=5;  // imposta l'uscita 5 di arduino
int bottone=8; //  USCITA DOVE  COLLEGARE IL PULSANTE 
int statoLed=LOW;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

byte mac[] = { 0x00, 0x23, 0xCD, 0x1A, 0x05, 0xEC };
byte ip[] = { 192 ,168 ,1 ,155 };
byte gateway[] = { 192 ,168 ,1 ,1 };
byte subnet[] = { 255 ,255 ,255 ,0 };
Server server(82); 

String readString = String(30);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void setup(){
pinMode(pinLed, OUTPUT);
pinMode(bottone, INPUT);
Ethernet.begin(mac, ip, gateway, subnet);
delay(1000);
pinMode(5, OUTPUT);
digitalWrite(5, LOW);
pinMode(7, OUTPUT);
digitalWrite(7, LOW);
pinMode(6, OUTPUT);
digitalWrite(6, LOW);
Serial.begin(9600);
} 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop(){
 int leggiBottone=digitalRead(bottone);
 
  if (leggiBottone == 1)
  {
     if (statoLed == LOW)
     {
 
       statoLed=HIGH;
       digitalWrite(pinLed, statoLed);
       delay(1000);                               //   ZONA RISERVATA AL PULSANTE
       Serial.println("LUCI ACCESE");
 
     } else {
 
       statoLed=LOW;
       digitalWrite(pinLed, statoLed);
       delay(1000);
       Serial.println("LUCI SPENTE");         //     include il messaggio seriale  dello stato del pulsante 
       
     }
     }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////    
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 30)
{
readString = readString + c;
}
if (c == '\n') {
Serial.print(readString);
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

if(readString.startsWith("GET /?out=5&status=1"))
{Serial.print("\n 5 HIGH \n");
digitalWrite(5, HIGH);
client.print("{\"status\" : \"1\" , \"out\" : \"");
client.print(5);
client.print("\"}");
}
if(readString.startsWith("GET /?out=5&status=0"))
{Serial.print("\n 5 LOW \n");
digitalWrite(5, LOW);
client.print("{\"status\" : \"0\" , \"out\" : \"");
client.print(5);
client.print("\"}");
}


if(readString.startsWith("GET /?out=7&status=1"))
{Serial.print("\n 7 HIGH LOW \n");
digitalWrite(7, HIGH);
delay(200);
digitalWrite(7, LOW);
client.print("{\"status\" : \"1\" , \"out\" : \"");
client.print(7);
client.print("\"}");
}


if(readString.startsWith("GET /?out=6&status=1"))
{Serial.print("\n 6 HIGH LOW \n");
digitalWrite(6, HIGH);
delay(200);
digitalWrite(6, LOW);
client.print("{\"status\" : \"1\" , \"out\" : \"");
client.print(6);
client.print("\"}");
}


if(readString.startsWith("GET /?out=all"))
{
Serial.print("\n OUT ALL\n");
client.print("{\"ip\" : \\", ");
client.print("\"devices\" : ");
client.print("[{ \"type\" : \"light\", \"name\" : \"Luci\", \"out\" : \"");
client.print("5");
client.print("\"}");
client.print(",{ \"type\" : \"gate\", \"name\" : \"Cancello Apertura totale\", \"out\" : \"");
client.print("7");
client.print("\"}");
client.print(",{ \"type\" : \"gate\", \"name\" : \"Cancello apertura parziale\", \"out\" : \"");
client.print("6");
client.print("\"}");
client.print("]}");
}
readString="";
client.stop();
}
}
}
}
}

Indipendentemente dagli errori e dalla soluzione usa la macro F() per risparmiare RAM nei
client.print(F("text"));

Ciao Uwe