IH all
I am starting to pull my hair out I cannot get this to work
#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 = 4 ; // 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 0xFFA857: // 1 button pressed
small_stepper.setSpeed(500); //Max seems to be 500
Steps2Take = 256 ; // Rotate CW
small_stepper.step(Steps2Take);
delay(2000);
break;
case 0xFF229D: // 3 button pressed
small_stepper.setSpeed(500);
Steps2Take = 768 ; // Rotate CCW
small_stepper.step(Steps2Take);
delay(2000);
break;
If your library files are not in the local/sketch folder, change the double-quotes to greater-than/less-than. For example, #include <Stepper.h> and #include <IRremote.h>
#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 = 4; // Signal Pin of IR receiver to Arduino Digital Pin 6 //// -> Is it connected to pin 4 or 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() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
unsigned long irValue = 0;
if (irrecv.decode( & results)) {
irValue = results.value;
Serial.println(irValue, HEX);
if (irValue == 0xFFA857) { // 1 button pressed
small_stepper.setSpeed(500); //Max seems to be 500
Steps2Take = 256; // Rotate CW
small_stepper.step(Steps2Take);
delay(2000);
} else if (irValue == 0xFF229D) { // 3 button pressed
small_stepper.setSpeed(500);
Steps2Take = 768; // Rotate CCW
small_stepper.step(Steps2Take);
delay(2000);
}
}
irrecv.resume(); //// -> You need it to receive the next value
}