I have the Windows version of Arduino 1.8.33.
The sketch drives a stepper motor with an A4988 driver. Momentary buttons activate the Stepper motor either CW or CCW respectively and when in the CW direction a valve is also operated. A 16x2 LCD with I2C backpack is to record Stepper Speed (calculated as ml/sec). Speed is modified with the use of a potentiometer.
After correcting the sketch for minor issues the error code is:
Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino Nano, ATmega328P"
exit status 1
Error compiling for board Arduino Nano.
I have:
Shutdown and restarted the computer.
I have uninstalled and reinstalled the Arduino IDE.
I have deleted all LiquidCrystal-I2C libraries and reinstalled a single version.
I have tried all that i am capable off and no change.
The sketch will compile when i delete all activities associated with the LCD.
I see on the internet that this problem has existed before, but i cannot find a solution. Anyone out there with a suggestion. I include the code.
#include <Stepper.h>
#include<Wire.h>
#include <LiquidCrystal_I2C.h>
#define LCD_COLS 16
#define LCD_ROWS 2
const int I2CAddr = 0x26;
LiquidCrystal_I2C lcd(I2CAddr, LCD_COLS, LCD_ROWS); // set the LCD address to 0x26 for a 16 chars and 2 line display
//Pins
//Buttons
const int CW = 8;
const int CCW = 9;
//Flush Stepper Motor
const int stp = 3;
const int dir = 2;
const int En = 4;
int stepdelay;
//Pinch Valve
const int Valve = 5;
//Pot
const int Pot = A0;
int val1;
int val2;
void setup() {
//Buttons
pinMode(CW, INPUT_PULLUP);
pinMode(CCW, INPUT_PULLUP);
//Stepper Motor via A4988
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
pinMode(En, OUTPUT);
digitalWrite(En, HIGH);
digitalWrite(dir, LOW);
//Solenoid Valve
pinMode(Valve, OUTPUT);
digitalWrite(Valve, LOW);
lcd.init(); // initialize the lcd
lcd.setCursor(0, 1);// Print a message to the LCD.
lcd.print("CW ml/sec");
}
void loop()
{
int val1 = analogRead(Pot);
val1 = map(val1, 0, 1023, 0, 20);
lcd.setCursor(1, 7);
lcd.print(val1);
if (digitalRead(CW) == LOW) {
digitalWrite(En, LOW);
digitalWrite(dir, HIGH);
digitalWrite(Valve, HIGH);
val2 = map (val1, 0, 20, 1, 4000);
stepdelay = val2;
digitalWrite(stp, HIGH);
delayMicroseconds(stepdelay);
digitalWrite(stp, LOW);
delayMicroseconds(stepdelay);
}
else if (digitalRead(CCW) == LOW) {
digitalWrite(En, LOW);
digitalWrite(dir, LOW);
int val2 = map(val1, 0, 20, 1, 4000);
stepdelay = val2;
digitalWrite(stp, HIGH);
delayMicroseconds(stepdelay);
digitalWrite(stp, LOW);
delayMicroseconds(stepdelay);
}
else {
digitalWrite(En, HIGH);
digitalWrite(dir, LOW);
digitalWrite(Valve, LOW);
}
}