Hello there,
i am using a simple code to allow a stepper motor to rotate a display for 180 degree cw when button (1) is pressed and rotate 180 degree ccw when button (2) is pressed. i have noticed the motor gets supper hot and it caused the gears to bend of heat. I need to be able to stop the current from the motor when Idle. (note, that I don't mind allowing the motor to rotate manually when idle)
i am using the following:
-Arduino uno R3
-L298N motor driver
-50byj46-6 stepper motor
-IR remote
-IR reciever
-15 V power source
- step down converter to power the Arduino
this is the code i am using,
// 1=180 CW
// 2=180 CCW
#include "Stepper.h"
#include "IRremote.h"
/----- Variables, Pins -----/
#define STEPS 32 // Number of steps per revolution of Internal shaft
int Steps2Take; // 2048 = 1 Revolution
int receiver = 6; // Signal Pin of IR receiver to Arduino Digital Pin 6
/-----( Declare objects )-----/
// Setup of proper sequencing for Motor Driver Pins
// In1, In2, In3, In4 in the sequence 1-3-2-4
Stepper small_stepper(STEPS, 8, 10, 9, 11);
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
void setup()
{
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
switch(results.value)
{
case 16724175: // >> button pressed
small_stepper.setSpeed(500); //Max seems to be 700
Steps2Take = 3180; // Rotate CW
small_stepper.step(Steps2Take);
//delay(200);
break;
case 16718055: // << button pressed
small_stepper.setSpeed(500);
Steps2Take = -3180; // Rotate CCW
small_stepper.step(Steps2Take);
//delay(200);
break;
}
irrecv.resume(); // receive the next value
}
}/* --end main loop -- */