CONTROL STEPPER IR REMOTE

STepper remote

The code can be downloaded at :

https://github.com/triantara/ARDUINO-TRIANTARA/blob/main/Stepper_remote.zip

#include “Stepper.h”
#include “IRremote.h”
#define STEPS 32 // Number of steps per revolution of Internal shaft
int Steps2Take; // 2048 = 1 Revolution
int receiver = 3; // Signal Pin of IR receiver to Arduino Digital Pin 6

// In1, In2, In3, In4 in the sequence 1-3-2-4
Stepper small_stepper(STEPS, 12, 10, 11, 9);
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 0x20F0E01F: // RIGHT button pressed
small_stepper.setSpeed(500); //Max seems to be 700
Steps2Take = 2048; // Rotate CW 360 deg
small_stepper.step(Steps2Take);
break;

case 0x20F0609F: // LEFT button pressed
small_stepper.setSpeed(500);
Steps2Take = -1024; // Rotate CCW 180 deg
small_stepper.step(Steps2Take);
break;
}
irrecv.resume(); // receive the next value
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s