I was trying to compile a code and i got the "Error compiling for Arduino Mega/mega 2560". help please

Arduino: 1.8.15 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

java.io.IOException: The system cannot find the path specified

at java.io.WinNTFileSystem.createFileExclusively(Native Method)

at java.io.File.createTempFile(File.java:2024)

at processing.app.BaseNoGui.saveFile(BaseNoGui.java:886)

at processing.app.SketchFile.save(SketchFile.java:287)

at processing.app.SketchController.ensureExistence(SketchController.java:775)

at processing.app.SketchController.build(SketchController.java:651)

at processing.app.Editor$BuildHandler.run(Editor.java:1632)

at java.lang.Thread.run(Thread.java:748)

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\DELL\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\DELL\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\DELL\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10815 -build-path C:\Users\DELL\AppData\Local\Temp\arduino_build_119006 -warnings=none -build-cache C:\Users\DELL\AppData\Local\Temp\arduino_cache_794908 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose G:\Main_Program\Main_Program.ino

unable to stat Sketch location: CreateFile G:\Main_Program\Main_Program.ino: The system cannot find the path specified.

Error compiling for board Arduino Mega or Mega 2560.

Hi @richieokello. If you check in your Windows file explorer, does the file G:\Main_Program\Main_Program.ino exist?

yes. it is

this is my main program

#include <SoftwareSerial.h>
#include <TinyGPS.h>
//long lat,lon; // create variable for latitude and longitude object
float lat, lon;
TinyGPS gps; // create gps object
SoftwareSerial mySerial(10, 11);
int pin1 = 3;// flip flop
int pin2 = 6;//buzzer/hazards
int pin3 = 7;//relay

void setup() {
pinMode(pin1, INPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
Serial.begin(9600);
mySerial.begin(9600);
int GSM_SEND();
int GSM_SEND2();
int GSM_RECEIVED();
int buzzer_hazards();
Serial2.begin(9600); // connect gps sensor

}

void GSM_SEND() {
while (Serial2.available()) { // check for gps data
if (gps.encode(Serial2.read())) // encode gps data
{
gps.f_get_position(&lat, &lon); // get latitude and longitude

  Serial.print("Position: ");

  //Latitude
  Serial.print("Latitude: ");
  Serial.print(lat, 6);

  Serial.print(",");

  //Longitude
  Serial.print("Longitude: ");
  Serial.println(lon, 6);
  mySerial.begin(9600);
  delay(1000);
  mySerial.println("AT");
  delay(500);
  mySerial.println("AT+CMGF=1");
  delay(500);
  mySerial.println("AT+CMGS=\"+254726876773\"\r");
  delay(500);
  mySerial.print("Car stolen... ");
  mySerial.print("Latitude: ");
  mySerial.print(lat, 6);
  mySerial.print("Longitude: ");
  mySerial.print(lon, 6);
  delay(500);
  mySerial.write(26);
}

}
}

void GSM_SEND2() {
while (Serial2.available()) { // check for gps data
if (gps.encode(Serial2.read())) // encode gps data
{
gps.f_get_position(&lat, &lon); // get latitude and longitude

  Serial.print("Position: ");

  //Latitude
  Serial.print("Latitude: ");
  Serial.print(lat, 6);

  Serial.print(",");

  //Longitude
  Serial.print("Longitude: ");
  Serial.println(lon, 6);
  mySerial.begin(9600);
  delay(1000);
  mySerial.println("AT");
  delay(500);
  mySerial.println("AT+CMGF=1");
  delay(500);
  mySerial.println("AT+CMGS=\"+254726876773\"\r");
  delay(500);
  mySerial.print("Last location... ");
  mySerial.print("Latitude: ");
  mySerial.print(lat, 6);
  mySerial.print("Longitude: ");
  mySerial.print(lon, 6);
  delay(500);
  mySerial.write(26);
}

}
}

void GSM_RECEIVED() {
{
delay(5000);
while (Serial.available()) {
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while (mySerial.available()) {
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
if ((int((mySerial.read()))) == (int(1122))) {
GSM_SEND2();
}
else if ((mySerial.read()) != (int(1122))) {
GSM_RECEIVED();
}
}
}

void buzzer_hazards() {
pin2 = HIGH;
delay(1000);
pin2 = LOW;
delay(1000);
}

void loop() {
digitalRead(pin1);
if (digitalRead(pin1) = HIGH) { // flip flop pin{
pin3 = HIGH;
Serial.print("loop1");
GSM_SEND();
GSM_RECEIVED();
pin3 = LOW;
while (pin3 = LOW) {
buzzer_hazards();
}
}
else if (digitalRead(pin1) = LOW) { //flip flop{
pin3 = HIGH;

Serial.print("loop2");

}
}

Is there anything special about the G: drive that would prevent the Arduino IDE from being able to access it? For example: a network or cloud drive.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.