salve ieri avevo caricato questo sketch
#include <SPI.h>
#include <SD.h>
float Vs;
float Vmax = 0;
float Vmin = 5;
byte Apin1 = A15;
byte n = 0;
byte in1 = 46;
byte ing1 = 1; //valore di in1
byte ou1 = 47;
File myFile;
void setup() {
pinMode(ou1, OUTPUT);
pinMode(in1, INPUT);
pinMode(53, OUTPUT);
Serial.begin(9600);
//-----------inizializzazione---------------
Serial.print("Initializing SD card...");
if (!SD.begin(53)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
void loop() {
for (n = 0; n < 50; n++) {
Vs = analogRead(Apin1) * 0.00489;
if (Vs > Vmax) {
Vmax = Vs;
} else if (Vs < Vmin) {
Vmin = Vs;
}
delayMicroseconds(900);
}
Vs = (Vmax - Vmin) * 2333.45; //potenza apparente in W
myFile = SD.open("potenza.txt", FILE_WRITE);
if (myFile) {
Serial.print("Writing to file...");
myFile.println(Vs);
myFile.close();
} else {
Serial.println("error opening for writeing file");
}
Vmax = 0;
Vmin = 5;
digitalWrite(ou1, HIGH);
delay(1000);
digitalWrite(ou1, LOW);
delay(5000);
if (ing1 == LOW)
{
while (ing1 == LOW)
{
ing1 = digitalRead(in1);
}
digitalWrite(ou1, HIGH);
delay(10000);
digitalWrite(ou1, LOW);
}
}
tuttavia mi sono accorto che mancava un digital read quindi stamattina ho provato a ricaricarlo , tuttavia ottengo sempre un messaggio di errore e la scheda esegue in automatico, appena attacco la porta usb, il vecchio sketch , mi da sempre lo stesso errore anche provando a caricare altri programmi.
Arduino:1.8.5 (Windows 10), Scheda:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
Lo sketch usa 13536 byte (5%) dello spazio disponibile per i programmi. Il massimo è 253952 byte.
Le variabili globali usano 1043 byte (12%) di memoria dinamica, lasciando altri 7149 byte liberi per le variabili locali. Il massimo è 8192 byte.
avrdude: ser_open(): can't open device "\.\COM3": Accesso negato.
avrdude: ser_drain(): read error: Handle non valido.
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Handle non valido.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Handle non valido.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Handle non valido.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Handle non valido.
avrdude: ser_recv(): read error: Handle non valido.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Handle non valido.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Handle non valido.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
non penso sia un problema del cavo dato che ne ho provati 2 ...