Slider Problem on dashboard

#18

Ok, i made 2 buttons Open/Close, now i see something strange about motor, when is idle make some tiny rotation, that can be a code problem?

#19

follow this tutorial and see if it works http://www.mrhobbytronics.com/arduino-stepper-motor-control/.
if it works without any issue then add the cayenne code.

#20

also go through this important post http://forum.arduino.cc/index.php?topic=284828.0 and http://forum.arduino.cc/index.php?topic=277692.0

#21

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…

#22

use the button from cayenne to test the code.

#23

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.

#24

what are the steps you are referring to?

#25

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.

1 Like
#26

Great. let me know if need further help.

#27

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 :slight_smile:

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.

#28

without

delay(50000);
digitalWrite(enablePin,HIGH);

#29

so the issue is solved, right?

#30

No, still not… can’t figure how to turn off motor after one use.

#31

Issue solved, thank shramik_salgaonkar

#32

should this, turn the motor OFF?

#33

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);
}

#34

it should work actually.

what happens if you remove this delay?

#35

Just try without delay, it works too

#36

you mean that the issue is solved?

#37

Yes !!!

Soon i will post my project on Cayenne soon !

2 Likes