**Libraries are dec
------------
#include <IRremote.h>
ong button4 = 0x9FA96F;
IRrecv irrecv(RECV_PIN);
decode_results results;
const int stepsPerRevolution = 200;
Stepper s1(200, 8,9,10,11);
Stepper s2(200, 2,3,4,5);
void setup() { Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true); // blink LED on P13 when IR signal is present
s1.setSpeed(60);
s2.setSpeed(60);
}
void loop()
{
if (irrecv.decode(&results))
{ if (results.value == button1)
{ s1.step(200); delay(500);
}
if (results.value == button2)
{ s1.step(-200); delay(500); }
if (results.value == button3)
{ s2.step(200); delay(500); }
if (results.value == button4)
{ s2.step(-200);
delay(500); }
irrecv.resume(); // Receive the next value
}
}
-------------------------------
The code below controls a servo and stepper motor via an IR remote. The servo is used as a lock/trigger mechanism while the stepper motor is used for the rotating base.
#include <IRremote.h>
long button1 = 0xAC516266;
long button1a = 0xE516266;
long button2 = 0xAD5163FB;
long button2a =0xAD5163FB;
long button3 = 0xBE15326E;
long button3a = 0xDB9D3097;
long button4 = 0x9FA96F;
long button4a = 0x9912B99A;
long button6 = 0x11;
long button6a = 0x811;
IRrecv irrecv(RECV_PIN);
decode_results results;
const int stepsPerRevolution = 200;
Stepper s1(200, 4,5,6,7);
Stepper s2(200, 8,9,10,11);
Servo myservo;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true); // blink LED on P13 when IR signal is present
s1.setSpeed(60);
s2.setSpeed(60);
myservo.attach(9);
}
void loop()
{ if (irrecv.decode(&results))
{ if (results.value == button1)
{ s1.step(200); delay(100);
} if (results.value == button1a)
{ s1.step(200); delay(100); }
if (results.value == button2)
{
s1.step(-200); delay(100);
}
if (results.value == button2a)
{
s1.step(-200); delay(100);
}
if (results.value == button3)
{
s2.step(200); delay(100);
}
if (results.value == button3a)
{
s2.step(200); delay(100); }
if (results.value == button4)
{
s2.step(-200); delay(100); }
if (results.value == button4a)
{
s2.step(-200); delay(100);
}
if (results.value == button6)
{
myservo.write(0);
delay(100);
}
if (results.value == button6a)
{
myservo.write(90);
delay(100);
}
irrecv.resume(); // Receive the next value
}
}
No comments:
Post a Comment