First of all thank you for your support ...
I am moving a stepper motor in CW and CCW direction and switch ON/OFF a led using Aruino Nano simply sending these commands by a PC Windows GUI made by Phyton, which send on its serial output the commands to arduino nano connected to USB (com7 port);
LED ON/OFF and stepper rotation works fine, but when the rotation of stepper is finished the 4 leds monted on stepper driver board remain ON and reset the micro using its push button they become OFF.
Now I create on the GUI a simple PUSH buttoms where I switch ON/FF the LED and Stepper ritation but when I want to reset the micro (it is just a RESET function for testing/trouble shooting purpose) it seems do not work and the stepper or LED ON/OFF (no relevant to the stepper control, but connected to ARDUINO) are not comandable..
This is the code
- Wiring List: *
-
#4 Blue Wire on White Connector *
-
#5 Pink Wire on White Connector *
-
#6 Yellow Wire on White Connector *
-
#7 Orange Wire on White Connector *
-
White Wire from D8(PIN12) to PIN RESET - ACTIVE LOW (PIN29) by resistor of 100 ohm *
***************************************************************************************************************/
#include <Stepper.h> // Stepper Library
#define STEPS 2038 // Number of Steps in one motor revolution (2048 TBV)
Stepper stepper(STEPS, 7, 5, 6, 4); //(D4 ORANGE), (D5-YELLOW), (D6-GREEN), (D7-BLUE) ARDUINO PINS/WIRE COLOR)
// Exchanging 7 with 4 order the stepper move only in one direction
//
int STEP_MOTOR_D7 = 7;
int STEP_MOTOR_D4 = 4;
int STEP_MOTOR_D5 = 5;
int STEP_MOTOR_D6 = 6;
int Backlight_D12 = 12; // Test light (Amber LED)*/
int Reset_D8 = 8;
//
void setup() {
pinMode(STEP_MOTOR_D7, OUTPUT);
pinMode(STEP_MOTOR_D4, OUTPUT);
pinMode(STEP_MOTOR_D7, OUTPUT); //CHANGE in D5
pinMode(STEP_MOTOR_D4, OUTPUT); //CHANGE in D6
pinMode(Backlight_D12, OUTPUT);
pinMode(Reset_D8, OUTPUT);
digitalWrite(Reset_D8, HIGH); // Reset inhibited
Serial.begin(9600);
}
/**************************************************************************************************************/
void loop() {
if (Serial.available()) {
unsigned char c = Serial.read(); /CHAR (from -128 to +127), UNSIGNED CHAR (from 0 to 255)/
if (c == '1') {
digitalWrite(Backlight_D12, HIGH);
delay(1);
}
else if (c == '2') {
digitalWrite(Backlight_D12, LOW);
delay(1);
}
else if (c == '3') {
stepper.setSpeed(1);
stepper.step(-2038); // This command permit a CCW rotaion (in my stepper being the mptor case mounted in reverse mode I put -2038 for CW)
stepper.setSpeed(0);
delay(500);
}
else if (c == '4') {
stepper.setSpeed(1);
stepper.step(2038); // This command permit a CW rotaion (in my stepper being the mptor case mounted in reverse mode I put 2038 for CW)
stepper.setSpeed(0);
delay(500);
}
else if (c == '5') {
digitalWrite(Reset_D8, LOW);
delay(2000); // 8000?
digitalWrite(Reset_D8, HIGH);
}
}
}
yesterday putting a 100ohm resistor between the RESET PIN and D8 the circuit worked. Today NO 