-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAutomatic_Roller_Blind.ino
67 lines (48 loc) · 1.55 KB
/
Automatic_Roller_Blind.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//You can find me on https://www.instagram.com/furmatech3d/
//I made this for DRV8825 and NEMA17 but you can change this values for your controller
#include <IRremote.h>
#include <IRremoteInt.h>
int dirPin = 7; //drv8825 s pin
int stepPin = 8;
int powER = 6; //which pin gives 5volt on arduino (for sleeping mode)
#include <AccelStepper.h>
#define motorInterfaceType 1 // it must be 1 for "Steppers Motors"
AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
int RECV_PIN = 11; //IR pin
IRrecv irrecv(RECV_PIN);
decode_results results;
#define CH1 0x3D9AE3F7 //up (controller's channel, you can change this channel code according to your remoter's channel)
#define CH2 0x1BC0157B //down
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(dirPin, OUTPUT);
pinMode(6, OUTPUT);
pinMode(stepPin, OUTPUT);
stepper.setMaxSpeed(2500); // set speed
stepper.setAcceleration(500); // set acceleration
}
void loop() {
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX); // prints remoter's channel to serial screen
if (results.value == CH1)
{
digitalWrite(6, HIGH);
stepper.moveTo(230000); //change this value according to rollerblind height. On NEMA17 and 16 microsteps it is 1.5 meters .
stepper.runToPosition();
delay(100);
digitalWrite(6, LOW);
}
if (results.value == CH2)
{
digitalWrite(6, HIGH);
stepper.moveTo(0);
stepper.runToPosition();
delay(100);
digitalWrite(6, LOW);
}
irrecv.resume();
}
}