Wire Cutter

This IS code (credit https://youtu.be/d7VzVV2itAo and https://youtu.be/Zejn2yLxjUs) I had complete my Project but Servo Motor Not working.

//------------------------------- librarys ----------------------------------

#include <LiquidCrystal.h>
#include <Servo.h>

//------------------------------- lcd ----------------------------------
LiquidCrystal lcd(12, 11, 2, 3, 4, 5);

//------------------------------- stepper ----------------------------------
#define stepPin 7
#define dirPin 8

//------------------------------- servo ----------------------------------
Servo snippers;
#define servo 10
#define openAngle 90
#define closedAngle 0

//------------------------------- input ----------------------------------

#define leftButton 14
#define rightButton 9
#define upButton 15
#define downButton 6

//------------------------------- user settings ----------------------------------
unsigned int wireLength = 0;
unsigned int wireQuantity = 0;

//------------------------------- system settings ----------------------------------
int state = 0;
int incrementSpeed = 1;
int previousWireLength = 0;
int previousWireQuantity = 0;
float cmPerStep = 0.18096;

void setup() {
Serial.begin(9600);

lcd.begin(16, 2); //LCD columns and rows

pinMode(upButton, INPUT_PULLUP);
pinMode(downButton, INPUT_PULLUP);
pinMode(leftButton, INPUT_PULLUP);
pinMode(rightButton, INPUT_PULLUP);

pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);

snippers.attach(servo);

snippers.write(openAngle);

delay(1000);
}

void loop() {
if (!digitalRead(rightButton)){
if(state == 5){
state = 0;
}
else{
state += 1;
}
delay(200);
lcd.clear();
}
if (!digitalRead(leftButton) && 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(“FAMOUS PADDLE”);
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 + “cm”);
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 + “cm 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/cmPerStep;
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(11, 1);
lcd.print(“NEXT>”);
delay(100);
}

int changeValue(int currentValue){
if (!digitalRead(upButton)) {
delay(100);
currentValue += incrementSpeed;

}
if (!digitalRead(downButton)) {
if(currentValue - incrementSpeed >= 0){
delay(100);
currentValue -= incrementSpeed;

}
else{
currentValue = 0;
}
}
if (!digitalRead(downButton) && !digitalRead(upButton)){
incrementSpeed = 1;
}
return currentValue;
}

void displayNavigation(){
lcd.setCursor(0, 1);
lcd.print("<BACK");
lcd.setCursor(11, 1);
lcd.print(“NEXT>”);
delay(100);
}

Can you please provide a link to the board that the Arduino is plugged into ?

How is the system powered ? Does the example servo Sweep program work ?

thanks, Dear for a reply. yes, example servo Sweep program is work.

check link below.

https://www.youtube.com/watch?v=d7VzVV2itAo

Powered By 9v - 2Am dc adapter and also try 12v - 2v dc adapter.

Component: 1. Nama 17 stepper Motor 2. Servo Futaba S3003 3. Arduino Nano 4. stepper motor driver A4988 5. 16 x 2 LCD 6. PCB terminal 7. push buttons 8. 14k ohm resistance. 9. 10k ohm Pot.

As I asked before. How is the system powered ?

PCB

https://drive.google.com/file/d/1DSLzDVMo6JiojSMfzBPa-z_zqhrwQ4i6/view?usp=sharing

https://drive.google.com/file/d/1Cj0PxUAcTFTerISk4DmLEbrgGFbc2pGK/view?usp=sharing

Powered By 9v - 2Am dc adapter and also try 12v - 2v dc adapter.

Have you got a diagram of the circuit ?

Yes, And the pcb circuit board is ready. Please prefer image in my first post.

Yes, And the pcb circuit board is ready. Please prefer image in my first post.

UKHeliBob: Have you got a diagram of the circuit ?

sdzafar: Yes, And the pcb circuit board is ready. Please prefer image in my first post.

Sorry, but I cannot find a circuit diagram anywhere in this thread. The pictures attached to post #1 are not circuit diagrams

Please check Google drive link which one I have already share. (Post #5)

You can find also in post #8

You can Check here also

Project credit : https://youtu.be/d7VzVV2itAo

And

https://youtu.be/Zejn2yLxjUs

sdzafar: Please check Google drive link which one I have already share. (Post #5)

You can find also in post #8

You can Check here also

Project credit : https://youtu.be/d7VzVV2itAo

And

https://youtu.be/Zejn2yLxjUs

None of them are circuit diagrams. At the best they are pictures of the PCB

Sorry for that I don’t Have circuit diagram. Just this.

sdzafar:
I don’t Have circuit diagram.

It’s easy enough to draw one with a pencil or pen and take a pic with your mobile.

This:

5f01a20382d8ffeab7488d529f2c57e8434eba76.jpg

… is at least a block diagram, but it doesn’t show the detail. I think what others are wanting to see is how the servo is powered.

That is pretty useless in understanding the circuit

Back to basics. Does the servo do anything when you power up the circuit ? If you turn the servo by hand with the power off does it move to the open position when you apply power ? How is the circuit powered ? You say that the Sweep example works. Was that with the servo connected to this board or connected directly to the Arduino ?

If you are trying to power a standard Futaba S3003 servo with any load on it from the Arduino Nano's 5V pin then that's why it won't work and you may damage the Arduino.

If you are trying to power a standard Futaba S3003 servo from a 9V or 12V power supply then that also won't work and you have probably killed the servo.

Steve

Does the servo do anything when you power up the circuit ? A: No, it doesn't. If you turn the servo by hand with the power off does it move to the open position when you apply power ? A:yes it move on both conditions, move by hand when I apply power and move by hand when power off. How is the circuit powered ? A: 9V 2Am. You say that the Sweep example works. Was that with the servo connected to this board or connected directly to the Arduino ? A: servo 1 wire connect with power supply amd 2 wire connect with arduino.

. After one or one and half hour I will send you circuit digram. I will draw by my hand. Thanks dear

A:yes it move on both conditions, move by hand when I apply power and move by hand when power off.

If you mean that you can move the servo by hand whether or not power is supplied to the system then it means that the servo is not receiving any power.

A: servo 1 wire connect with power supply amd 2 wire connect with arduino.

So not with the servo plugged into this board then ?

Does the servo do anything when you power up the circuit ? A:No Nothing.

If you turn the servo by hand with the power off does it move to the open position when you apply power ? A:motor move both condition. when apply power and when I remove from circut (power off).

How is the circuit powered ? A: 9V-2Am power adepter

You say that the Sweep example works. Was that with the servo connected to this board or connected directly to the Arduino ? A: Servo Motor connect with 2 wire arduino and one wire connect with (-) power.

Circuit Diagram :

https://drive.google.com/file/d/19TtwRewPOGIcigtDqW2obD99enNZEDo7/view?usp=sharing

-----slipstick---- Thanks For reply.

But Stepper motor work properly. which is also connected in the same circuit board.