Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Error in VM and not in Arduino IDE (Read 1640 times)
sprinkfitter
Newbies
*
Offline


Posts: 2
Location: Louisville Ky
Joined: Feb 16th, 2017
Error in VM and not in Arduino IDE
Jan 4th, 2019 at 4:18am
Print Post  
Seems like I have a very odd problem.  I tried to compile a sketch in VS with VM and I get this error.  I decided to copy it to the Arduino IDE and it compiles and upload to my esp32s board and runs perfect.  Why is this? Undecided Undecided

Error compiling project sources
Debug build failed for project 'Relays_Test'
Relays_Test_esp32.ino: 6:5: error: redefinition of 'int relayPin0
   int relayPin0 = 12
Relays_Test.ino:6: note  int relayPin0 previously defined here
   int relayPin0 = 12
 
Relays_Test_esp32.ino: 7:5: error: redefinition of 'int relayPin1
   int relayPin1 = 27
Relays_Test.ino:7: note  int relayPin1 previously defined here
   int relayPin1 = 27
 
Relays_Test_esp32.ino: In function void setup()
 
Relays_Test_esp32.ino: 11:6: error: redefinition of 'void setup()  

The Sketch is a relay sketch

Code
Select All
int relayPin0 = 12;
int relayPin1 = 27;
int relayPin2 = 16;
int relayPin3 = 17;

void setup() {
	pinMode(relayPin0, OUTPUT);
	pinMode(relayPin1, OUTPUT);
	pinMode(relayPin2, OUTPUT);
	pinMode(relayPin3, OUTPUT);

	digitalWrite(relayPin0, HIGH);
	digitalWrite(relayPin1, HIGH);
	digitalWrite(relayPin2, HIGH);
	digitalWrite(relayPin3, HIGH);
}

void loop() {

	digitalWrite(relayPin0, LOW);
	delay(2000);
	digitalWrite(relayPin0, HIGH);
	delay(4000);

	digitalWrite(relayPin1, LOW);
	delay(2000);
	digitalWrite(relayPin1, HIGH);
	delay(4000);

	digitalWrite(relayPin2, LOW);
	delay(2000);
	digitalWrite(relayPin2, HIGH);
	delay(4000);

	digitalWrite(relayPin3, LOW);
	delay(2000);
	digitalWrite(relayPin3, HIGH);
	delay(4000);
} 

« Last Edit: Jan 4th, 2019 at 2:43pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Error in VM and not in Arduino IDE
Reply #1 - Jan 4th, 2019 at 2:49pm
Print Post  
Is it possible that your test in the arduino ide was with code you had created in a different folder to the folder used in your Visual Studio project?

If so then I might guess that you have another .ino file in the project folder that contains duplicate code? The files in the project folder are always compiled even if you have not included them in the project explorer. ( For Arduino, all .ino code is combined into a hidden .cpp at compile time.)

This differs to how C# works because the arduino ide will compile all .ino and .cpp files in the project folder. There are some options to change this behaviour but the way it works actually makes more sense when switching between Arduino IDE's.
  
Back to top
IP Logged
 
sprinkfitter
Newbies
*
Offline


Posts: 2
Location: Louisville Ky
Joined: Feb 16th, 2017
Re: Error in VM and not in Arduino IDE
Reply #2 - Jan 5th, 2019 at 3:27am
Print Post  
I guess I will try to delete the file and open up a new file and name it something else.  Maybe that will work
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Error in VM and not in Arduino IDE
Reply #3 - Jan 5th, 2019 at 5:17pm
Print Post  
It's supposed to be simple. Either you have a duplicate .ino that can be seen in windows explorer or you do not. If not then please zip and post the project folder and files here using the reply button or email to info[at]visualmicro.com




note: if you start renaming things you should bear in mind that arduino does not use projects so to make a valid arduino sketch the folder name and an .ino name must be the same. In Visual Micro this applies but also the project name must have the same name.
« Last Edit: Jan 5th, 2019 at 5:17pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint