-
Notifications
You must be signed in to change notification settings - Fork 1
/
sketchIR_SMotor.ino
50 lines (44 loc) · 1.12 KB
/
sketchIR_SMotor.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <IRremote.h>
#include "Stepper.h"
//Variables
#define STEPS 32 //Number of steps per revolution of internal shaft
int Steps2Take; // 2048=1 Revolution
int receiver = 6;
IRrecv irrecv(receiver);
decode_results results;
//DECLare objects
Stepper small_stepper(STEPS,8,10,9,11);
void setup() {
// put your setup code here, to run once:
//Serial.begin(9600); To initialize the console to print
irrecv.enableIRIn(); // start the receiver
}
// + FFA857
// - FFE01F
void loop() {
// put your main code here, to run repeatedly:
if(irrecv.decode(&results)) //Is there an IR signal?
{
switch(results.value)
{
case 0xFFA857: //Plus button
{
small_stepper.setSpeed(700);
Steps2Take =2048;
small_stepper.step(Steps2Take);
delay(2000);
break;
}
case 0xFFE01F:
{
small_stepper.setSpeed(500);
Steps2Take=-2048;
small_stepper.step(Steps2Take);
delay(2000);
break;
}
}
irrecv.resume();// receive the next value
}
delay(100);
}