I have been using arduino for some time now and have been tinkering around with it. My most recent project is a camera slider and for the most part everything was going great until i came home and turned it on to be greeted with by LCD having blocks on the last 8 segments of both rows. I've searched for possible causes and checks continuity of my circuit and everything seems to be linked correctly, yet it still will not show the second portion of the screen. Please refer to the image to see what i'm talking about, i've also linked my code incase however it still contains my slider coding.
#include <MultiStepper.h>
#include <AccelStepper.h>
#include <LiquidCrystal.h>
AccelStepper stepperX;
#define home_switch 13
// Stepper Travel Variables
long TravelX; // Value of stepper
int move_finished=1;
long initial_homing=-1;
long SpeedX; //Value of speed
long AcccelX; //Value of acceleration
const int rs = 12, en = 11, d4 = 6, d5 = 7, d6 = 9, d7 = 8; // LCD
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
lcd.print("HOMING");
lcd.setCursor(0, 1);
lcd.print("Please Wait");
pinMode(home_switch, INPUT_PULLUP);
delay(5);
stepperX.setMaxSpeed(200.0);
stepperX.setAcceleration(100.0);
// Start Homing procedure of Stepper Motor at startup
Serial.print("Stepper is Homing . . . . . . . . . . . ");
while (digitalRead(home_switch)) {
stepperX.moveTo(initial_homing); // Set the position to move to
initial_homing--;
stepperX.run(); // Start moving the stepper
delay(5);
}
stepperX.setCurrentPosition(0);
stepperX.setMaxSpeed(200.0);
stepperX.setAcceleration(100.0);
initial_homing=1;
while (!digitalRead(home_switch)) { // Make the Stepper move CW until the switch is deactivated
stepperX.moveTo(initial_homing);
stepperX.run();
initial_homing++;
delay(5);
}
stepperX.setCurrentPosition(0);
Serial.println("Homing Completed");
Serial.println("");
stepperX.setMaxSpeed(300.0);
stepperX.setAcceleration(100.0);
Serial.println("Enter Travel distance (Positive for CW / Negative for CCW and Zero for back to Home): ");
lcd.begin(16,2);
lcd.setCursor(0, 0);
lcd.print("Speed:");
lcd.setCursor(7, 0);
lcd.print(SpeedX);
lcd.setCursor(8, 1);
lcd.print(TravelX);
lcd.setCursor(0, 1);
lcd.print("Move to:");
delay(3000);
}
void loop() {
while (Serial.available()>0) {
move_finished=0;
TravelX= Serial.parseInt();
if (TravelX < 0 || TravelX > 1850) { // Make sure the position entered is not beyond the HOME or MAX position
Serial.println("");
Serial.println("Please enter a value greater than zero and smaller or equal to 1850.....");
Serial.println("");
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Wrong Value");
lcd.setCursor(0, 1);
lcd.print("Range: 0-1850");
delay(2000);
} else {
Serial.print("Moving stepper into position: ");
Serial.println(TravelX);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Moving to");
lcd.setCursor(10, 0);
lcd.print(TravelX);
lcd.setCursor(0, 1);
lcd.print(TravelX/60);
stepperX.moveTo(TravelX); // Set new moveto position of Stepper
delay(1000);
}
}
if (TravelX >= 0 && TravelX <= 1850) {
// Check if the Stepper has reached desired position
if ((stepperX.distanceToGo() != 0)) {
stepperX.run(); // Move Stepper into position
}
// If move is completed display message
if ((move_finished == 0) && (stepperX.distanceToGo() == 0)) {
Serial.println("COMPLETED!");
Serial.println("");
Serial.println("Enter Travel distance (Positive for CW / Negative for CCW and Zero for back to Home): ");
move_finished=1;
delay(500);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Move completed");
lcd.setCursor(0, 1);
lcd.print("Please Wait");
delay(2000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Speed:");
lcd.setCursor(7, 0);
lcd.print(SpeedX);
lcd.setCursor(8, 1);
lcd.print(TravelX);
lcd.setCursor(0, 1);
lcd.print("Move to:");
}
}
}