This project is all about adding Luxury to life using bolt IoT module. In this project I am going to build automatic window curtain that will open up automatically giving you some sunshine every morning.
First lets get stepper motor working
Now lets make curtain
Caution: Please ask your parents permission to drill window frame for fixing clamp. It is likely that they deny permission for your crazy idea, my case was same so I drilled and fixed the clamp on my bed’s headboard.
It might look something like this:
Arduino coding
Upload the code below to Arduino
#include <Stepper.h>
// Created by Aashik Pradeep on 20/1/2021
int sensorPin = A0;
// select the input pin for the potentiometer
int sensorP = A2;
int sensorValue = 0;
int sensorLValue=0;
const int stepsPerRevolution = 200;
// change this to fit the number of steps per revolution
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(85);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(sensorPin);
sensorLValue = analogRead(sensorP);
if(sensorValue>50&&sensorLValue<5){
Serial.println("clockwise");
myStepper.step(200); }
if( sensorLValue>50&&sensorValue<5){
// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-200);
}
}
Here I have used analog pins instead of digital pins to avoid pullup resistors and its sensitivity issues.
When the Bolt module’s digital pin gives output the analog pin in arduino will read a value between 50 and 5.
When the pin gets input the stepper takes 200 steps clockwise or anticlockwise accordingly.
Here I have used analog pins instead of digital pins to avoid pullup resistors and its sensitivity issues.
When the Bolt module’s digital pin gives output the analog pin in arduino will read a value between 50 and 5.
When the pin gets input the stepper takes 200 steps clockwise or anticlockwise accordingly.
Connecting Bolt to Arduino
Connect A0 AND A2 pins to digital pins 1 and 2 of Bolt module respectively also short the ground of Bolt and Arduino as shown in circuit diagram above
Step 1: Software coding on Bolt
Create a product on bolt cloud initializing two digital pins of Bolt module.
Here I have used digital pin 0 and digital pin 1, connect them using jumper wires. I have used html language to write the code so that it is simple and all can understand, but if you are a pro go for JavaScript interesting button layouts are readily available in Docs section in Bolt cloud ( https://docs.boltiot.com/docs/controlling-devices ).
<html>
<head>
<title>Bolt IoT Platform</title>
<script type="text/javascript"
src="https://cloud.boltiot.com/static/js/boltCommands.js">
</script>
<script>
setKey('','');
</script>
</head>
<body>
<center>
<button onclick="digitalWrite(0, 'HIGH');">
RISE CURTAIN
</button>
<button onclick="digitalWrite(0, 'LOW');">
STOP
</button>
<button onclick="digitalWrite(1, 'HIGH');">
LOWER CURTAIN
</button>
<button onclick="digitalWrite(1, 'LOW');">
STOP
</button>
</center>
</body>
</html>
Link the product to the Bolt device
By now its all set to run, now use 5v power source (power bank) to power Bolt module and Arduino and stepper motor drive.
Switch on the 12v power supply to the stepper motor drive. Open bolt app on phone and you will find “RISE CURTAIN” button to rise the curtain & “LOWER CURTAIN”to lower the curtain and stop button to stop rising or lowering of the curtain at desired position.
The good news is seeing this mom allowed me to fix it on window. If you are doing so please make sure there is a power supply near window so u can power 12v external power source for stepper motor.
Making automatic curtain smart
Using integromat you can make your curtain smarter. This will enable the curtain to operate at particular time in a day without your interference.
Here I have used integromat to open the curtain automatically at 6:00am every day and shut it at 7:00pm every day.
Step 2: Linking integromat
Now you have automated rising of curtain ,for automating lowering of curtain do the same steps except of pin 0 use pin 1.
Watch our project in action:
Getting up in the morning with sunshine already in your room is likely to make you happy and energetic. Also enjoy the ease of lowering and rising the curtain at your comfort place without getting up. Hope this Bolt Iot project brings some sunshine to you and your room.
Check out the Bolt IoT and ML training. This online video training is excellent for those who want to start with IoT and ML because it teaches you to build projects from the basics. Click on the button below to know more about the training.