Thank you PaulS sir,
As i am new to programming, i partially understand your suggestions & tried to modify the code but still some errors are showing
//------------------------------- librarys ----------------------------------
#include <LiquidCrystal.h>
#include <Servo.h>
#include <Keypad.h>
//------------------------------- lcd ----------------------------------
const int rs = 11, en = 12, d4 = 2, d5 = 3, d6 = 4, d7 = 5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//------------------------------- stepper ----------------------------------
#define stepPin 7
#define dirPin 8
//------------------------------- servo ----------------------------------
Servo snippers;
#define servo 10
#define openAngle 180
#define closedAngle 0
//------------------------------- input ----------------------------------
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char key;
//define the cymbols on the buttons of the keypads
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); // Keypad Library definition
volatile int firstnumber=99; // used to tell how many numbers were entered on keypad
volatile int secondnumber=99;
volatile int thirdnumber=99;
volatile int fourthnumber=99;
// Variables to hold length and quantity
int keyfullnumber=0; // used to store the final length value
//------------------------------- user settings ----------------------------------
unsigned int wireLength = 0;
unsigned int wireQuantity = 0;
//------------------------------- system settings ----------------------------------
int state = 0;
int previousWireLength = 0;
int previousWireQuantity = 0;
float mmPerStep = 0.18096;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2); //LCD columns and rows
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
snippers.attach(servo);
snippers.write(openAngle);
delay(1000);
}
void loop() {
char keypressed = keypad.getKey(); // Get value of keypad button if pressed
if (keypressed != NO_KEY){ // If keypad button pressed check which key it was
if (key == '#'){
if(state == 5){
state = 0;
}
else{
state += 1;
}
delay(200);
lcd.clear();
}
if (key == '*' && state > 0 && state < 4){
state -=1;
delay(200);
lcd.clear();
}
}
switch (state){
case 0:
homeScreen();
break;
case 1:
chooseWireLength();
break;
case 2:
chooseWireQuantity();
break;
case 3:
confirm();
break;
case 4:
currentlyCutting();
break;
case 5:
finishedCutting();
break;
}
}
void homeScreen(){
lcd.setCursor(0, 0);
lcd.print("WIRE CUTTER");
lcd.setCursor(0, 1);
lcd.print("UDAY");
lcd.setCursor(11, 1);
lcd.print("NEXT>");
delay(100);
}
void chooseWireLength(){
wireLength = changeValue(wireLength);
//clear LCD if required
if(previousWireLength != wireLength){
lcd.clear();
previousWireLength = wireLength;
}
//Display information on LCD
lcd.setCursor(0, 0);
lcd.print("LENGTH:" + (String)wireLength + "mm");
displayNavigation();
}
void chooseWireQuantity(){
wireQuantity = changeValue(wireQuantity);
//clear LCD if required
if(previousWireQuantity != wireQuantity){
lcd.clear();
previousWireQuantity = wireQuantity;
}
//Display information on LCD
lcd.setCursor(0, 0);
lcd.print("QUANTITY:" + (String)wireQuantity);
displayNavigation();
}
void confirm(){
lcd.setCursor(0, 0);
lcd.print((String)wireLength + "mm x " + (String)wireQuantity + "pcs");
lcd.setCursor(0, 1);
lcd.print("<BACK");
lcd.setCursor(10, 1);
lcd.print("START>");
delay(100);
}
void currentlyCutting(){
lcd.setCursor(0, 0);
lcd.print((String)0 + "/" + (String)wireQuantity);
lcd.setCursor(0, 1);
lcd.print("???s");
int stepsToTake = (int)wireLength/mmPerStep;
for(int i = 0; i < wireQuantity; i++){
unsigned long timeForOneCycle = millis();
digitalWrite(dirPin,HIGH);
for(int x = 0; x < stepsToTake; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
lcd.setCursor(0, 0);
lcd.print((String)(i+1) + "/" + (String)wireQuantity);
snippers.write(closedAngle);
delay(600);
snippers.write(openAngle);
delay(600);
lcd.setCursor(0, 1);
unsigned long timeRemaining = ((millis() - timeForOneCycle)*(wireQuantity - (i+1)))/1000;
lcd.print((String)timeRemaining + "s ");
}
wireLength = 0;
wireQuantity = 0;
state = 5;
}
void finishedCutting(){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("CUTTING COMPLETE");
lcd.setCursor(0, 1);
lcd.print("UDAY");
lcd.setCursor(11, 1);
lcd.print("NEXT>");
delay(100);
}
void displayNavigation(){
lcd.setCursor(0, 1);
lcd.print("<BACK");
lcd.setCursor(11, 1);
lcd.print("NEXT>");
delay(100);
}
void changeValue(int currentValue){ // Used to create a full number from entered numbers
char keypressed = keypad.getKey(); // Get value of keypad button if pressed
if (keypressed != NO_KEY){ // If keypad button pressed check which key it was
keypressed = keypad.getKey();
}
return currentValue; // Reset numbers to get ready for new entry
}
I got the error
In function 'void chooseWireQuantity()':
error: void value not ignored as it ought to be
wireQuantity = changeValue(wireQuantity);
Same error for 'void chooseWireLength()':
I search the google for the error, but couldnt understand much. I updated the my latest versions of libraries.
Please help on error & any other help in modifying code to simplify will be helpful.
Thank you very much for being with me with patience.