At the moment i don’t have buttons to test that code. Anyway i found how i can reduce/increase speed, as a drive i use a expansion board A4988 / DRV8825, i reduce current from board pot… only problem at this moment is that tiny laps on idle…
use the button from cayenne to test the code.
It’s ok for now, i reduce current and i put a 12v cooler on him, next part is to attach at greenhouse window to calculate rotation and speed, i will use 2 steps for open and 2 steps for close.
what are the steps you are referring to?
I mean i will use 2 rotation for open the window and 2 rotation for close. i bought all the mats i need, now i have to do window mechanics.
Great. let me know if need further help.
Hello,
I found my problem about tiny laps, was about that stepper motor stay on power on, can’t figured how to put back to sleep after i use it, my setup about it is:
Variables:
const int stepPin = 10;
const int dirPin = 11;
const int enablePin = 12;
in void setup it’s like that
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(enablePin,OUTPUT);
And for Cayenne
CAYENNE_IN(20)
{
int x = getValue.asInt();
if (x == 1){
digitalWrite(enablePin,LOW);
digitalWrite(dirPin,LOW);
for(int x = 1; x < 500; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
delay(50000);
digitalWrite(enablePin,HIGH);}
}
}
When i power arduino my motor stay on power off, but at first use he stay power on and i don’t know how to put on power off and waiting for next use.
without
delay(50000);
digitalWrite(enablePin,HIGH);
so the issue is solved, right?
No, still not… can’t figure how to turn off motor after one use.
Issue solved, thank shramik_salgaonkar
should this, turn the motor OFF?
It turns the motor off on arduino starts, then i use that code, i don’t know if is right but for my works:
CAYENNE_IN(20)
{
int x = getValue.asInt();
if (x == 1){
digitalWrite(enablePin,LOW);
digitalWrite(dirPin,LOW);
for(int x = 1; x < 5000; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(100);
digitalWrite(stepPin,LOW);
delayMicroseconds(100);
}
delay(30000);
digitalWrite(enablePin,HIGH);
}
it should work actually.
what happens if you remove this delay?
Just try without delay, it works too
you mean that the issue is solved?
Yes !!!
Soon i will post my project on Cayenne soon !