I have been shifting my arduino work over to VScode. I have everything working it seems, but intellisense seems to think things aren't ok.
Here is my script:
#include <SoftwareSerial.h>
#include "DualTB9051FTGMotorShieldMod3230.h"
// Declaring remapping for motor 1
unsigned char M1EN = 22;
unsigned char M1DIR = 7;
unsigned char M1PWM = 9;
unsigned char M1DIAG = 6;
unsigned char M1OCM = A0;
// Declaring remapping for motor 2
unsigned char M2EN = 4;
unsigned char M2DIR = 8;
unsigned char M2PWM = 10;
unsigned char M2DIAG = 12;
unsigned char M2OCM = A1;
// Declaring remapping for motor 3
unsigned char M3EN = 23;
unsigned char M3DIR = 27;
unsigned char M3PWM = 45;
unsigned char M3DIAG = 31;
unsigned char M3OCM = A2;
// Just in case setup for motor 4
unsigned char M4EN = 25;
unsigned char M4DIR = 29;
unsigned char M4PWM = 46;
unsigned char M4DIAG = 33;
unsigned char M4OCM = A4;
// Command to perform remaps
DualTB9051FTGMotorShieldMod3230 md(M1EN,M1DIR,M1PWM,M1DIAG,M1OCM,M2EN,M2DIR,M2PWM,M2DIAG,M2OCM,M3EN,M3DIR,M3PWM,M3DIAG,M3OCM,M4EN,M4DIR,M4PWM,M4DIAG,M4OCM);
// Declaring variables
int motorSelect;
String recM = "";
int M = 0;
int t;
void setup(){
// Initializing communication
Serial.begin(9600); //Open serial communications with computer and wait for port to open:
Serial2.begin(9600); //Open serial communications with the other Arduino board
//Initializing motors
md.init();
md.enableDrivers();
}
void loop() {
while(Serial2.available() > 2){ //If the XBee has 3 or more numbers to read
if(Serial2.read() != 255){ //If the first byte isn't 255
continue; //Skip the rest
}
motorSelect = Serial2.read(); // Identifies which motor is being ordered
delay(50);
recM = Serial2.readStringUntil('\n');
M = recM.toFloat();
delay(50);
Serial.read();
t = 1000 * Serial2.read();
switch(motorSelect){ // If the orders are for motor 1
case 1:
Serial.println("Turning on motor 1");
runMotor1();
delay(t);
Serial.println("Turning Off Motor");
motorsOff();
break;
case 2: // If the orders are for motor 2
Serial.println("Turning on motor 2");
runMotor2();
delay(t);
Serial.println("Turning Off Motor");
motorsOff();
break;
case 3: // If the orders are for motor 3
Serial.println("Turning on motor 3");
runMotor3();
delay(t);
Serial.println("Turning Off Motor");
motorsOff();
}
motorSelect = 0; // Resets the motor selection order
}
}
The script works, uploading poses no problems and arduino behaves as expected. However, Intellisense thinks that the libraries that are included don't exist.
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\falco\OneDrive\Documents\Arduino\Mechatronics\Mechatronics-Robot\Pm6 Demo\MegaV2\MegaV2.ino).
cannot open source file "SoftwareSerial.h"
cannot open source file "DualTB9051FTGMotorShieldMod3230.h"
This problem also extends to functions I have written myself. Where again, uploading and running poses no problems, but intellisense thinks there is a problem.The hint is obviously I need to update my includePath. But I am uncertain on how to do so. Where is this done?
This also raises the question of the location of the library folder. Before starting my switch to vscode. I was working on the arduino IDE 2.0, and had that libraries folder in C:\Users\falco\OneDrive\Documents\Arduino\libraries
It looks like the vscode arduino extension located this automatically and set the sketchbook to the same location as my arduino 2.0 IDE sketchbook. How do I control this? This is actually very convenient and want to leave it this way, but would like to understand what happened and how to control it in case I need to fix it manually.