I have Atmel Studio 7.0.1417 running on a W10 laptop. I would like to make a project using an existing Arduino sketch that compiles and loads correctly on an Uno.
I am confused about how to take an existing Arduino sketch and make a new project in Atmel Studio. No matter what I try, including "New Arduino Project" from the file menu and vMicro New Arduino Project or Existing Arduino Project, in addition to the IDE not seeming to recognize keywords of the Arduino IDE, I also get this error consistently: "Visual Micro Error reading variants path". I will typically get several instances of this error when trying to bring in the Arduino sketch, or even if I just try to start a new blank project without any code.
If I try to build the project, I get not only the error mentioned above, but this in the output area:
Compiling 'Sleep_mode_test' for 'Arduino/Genuino Uno'
System.ArgumentException: The path is not of a legal form.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.DirectoryInfo.Init(String path, Boolean checkHost)
at System.IO.DirectoryInfo..ctor(String path)
at Visual.Micro.MiroAppAPI.SketchCompiler.CreateFileTimeListXml(String fileType, String sPath, String outputPath)
at Visual.Micro.MiroAppAPI.SketchCompilerArduino._compile(SketchBuilder lsketch, String primaryClassName, Boolean verbose, Boolean isDebug)
at Visual.Micro.MiroAppAPI.SketchCompilerArduino.compile(SketchBuilder lsketch, String primaryClassName, Boolean verbose, Boolean isDebug)
at Visual.Micro.Visual.Studio.Arduino.AddInApp._CompileDo(Object oProject, Boolean IsDebugStartCommand, Boolean isRebuild, Boolean UseGdbIfAvailable)
at Visual.Micro.Visual.Studio.Arduino.AddInApp.CompileDo(Object oProject, Boolean IsDebugStartCommand, Boolean isRebuild, Boolean UseGdbIfAvailable)
at Visual.Micro.Visual.Studio.Arduino.AddInApp.OnBeforeCommandEvent(String sGuid, Int32 ID, Object CustomIn, Object CustomOut, Boolean& CancelDefault)
I have no idea what all this means or how to correct it.
If it will help, here is the entire sketch:
#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/io.h>
int wakePin = 2; // pin used for waking up
int led=13;
void wakeUpNow() {
// execute code here after wake-up before returning to the loop() function
// timers and code using timers (serial.print and more...) will not work here.
// we don't really need to execute any special functions here, since we
// just want the thing to wake up
}
void setup() {
pinMode(wakePin, INPUT_PULLUP);
pinMode(led, OUTPUT);
attachInterrupt(0, wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function wakeUpNow when pin 2 gets LOW
Serial.begin(9600);
}
void sleepNow() {
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
sleep_enable(); // enables the sleep bit in the mcucr register
attachInterrupt(0,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
sleep_mode(); // here the device is actually put to sleep!!
// THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
sleep_disable(); // first thing after waking from sleep: disable sleep...
detachInterrupt(0); // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time.
Serial.println("I'm awake!");
}
void loop() {
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
sleepNow(); // sleep function called here
}