I was trying to compile my code but the No connection established error showed up
It happened after I downloaded the L298N library by Andrea Lombardo
I didn't make changes to the code after i installed the library but i made sure to compile it just in case.
My code:
#define VRX_PIN A1 // Arduino pin connected to VRX pin
#define VRY_PIN A2 // Arduino pin connected to VRY pin
#define LEFT_THRESHOLD 500
#define RIGHT_THRESHOLD 530
#define UP_THRESHOLD 500
#define DOWN_THRESHOLD 524
#define COMMAND_NO 0x00
#define COMMAND_LEFT 0x01
#define COMMAND_RIGHT 0x02
#define COMMAND_UP 0x04
#define COMMAND_DOWN 0x08
int xValue = 0 ; // To store value of the X axis
int yValue = 0 ; // To store value of the Y axis
int command = COMMAND_NO;
void setup() {
Serial.begin(9600) ;
}
void loop() {
// read analog X and Y analog values
xValue = analogRead(VRX_PIN);
yValue = analogRead(VRY_PIN);
// converts the analog value to commands
// reset commands
command = COMMAND_NO;
// check left/right commands
if (xValue < LEFT_THRESHOLD)
command = command | COMMAND_LEFT;
else if (xValue > RIGHT_THRESHOLD)
command = command | COMMAND_RIGHT;
// check up/down commands
if (yValue < UP_THRESHOLD && yValue > 200)
command = command | COMMAND_UP;
else if (yValue > DOWN_THRESHOLD && yValue < 800)
command = command | COMMAND_DOWN;
// NOTE: AT A TIME, THERE MAY BE NO COMMAND, ONE COMMAND OR TWO COMMANDS
// print command to serial and process command
if (command & COMMAND_LEFT) {
Serial.println("COMMAND LEFT");
// TODO: add your task here
}
if (command & COMMAND_RIGHT) {
Serial.println("COMMAND RIGHT");
// TODO: add your task here
}
if (command & COMMAND_UP) {
Serial.println("COMMAND UP");
// TODO: add your task here
}
if (command & COMMAND_DOWN) {
Serial.println("COMMAND DOWN");
// TODO: add your task here
}
xValue = analogRead(VRX_PIN);
yValue = analogRead(VRY_PIN);
// print data to Serial Monitor on Arduino IDE
Serial.print("x = ");
Serial.print(xValue);
Serial.print(", y = ");
Serial.println(yValue);
}
Im running Arduino IDE 2.3.2 on windows 10
The board is selected as Arduino Uno on COM3 while i compiled
I also couldn't open the example code from the library