Hi there,
a while ago i stumbled upon this (formerly Kickstarter) project; https://thepresent.is/ An annual clock (or a month/day version). A clock that does one rotation a year. I tried to contact them about availability, but with no response. So I decided to try to make one.
I think I have the hardware figured out;
Arduino Uno, a stepper motor + ULN2003 board (more in the pictures)
The thing is, I am not good at programming.
I am trying to write a code that would: Rotate the motor one step at a time in a sequence usual to this stepper motor. In between these steps, I added a sequence for all 4 poles of the motor to be turned off. To save some power, as one step is ca. 2 hours apart.
Additionally, I would like to have a function of fast spinning, turned on with a button, so I can set the clock when first turned on (or after a power shortage). This doesn't have to be (and by design can't) precise.
This part I cant figure out.
Id like to have a button (with 10k resistor) to be plugged to pin 12 + ground for this function.
Could you guys help me to write this part of program?
const int in1 = 8;
const int in2 = 9;
const int in3 = 10;
const int in4 = 11;
const int button = 12;
int fast = 10 ; //delay for fast forward and and one step
int Delay = 863 ; //delay for in between steps
//2037.8864 = 1 rotation
//4076 = 1 rotation with delay steps
void setup() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(button, INPUT);
}
void loop() {
if(digitalRead(button) == LOW) {
ticking();}
else {
fastForward();}
}
void ticking() {
step1();
off();
step2();
off();
step3();
off();
step4();
off();
step5();
off();
step6();
off();
step7();
off();
step8();
off();
}
void fastForward() {
step1();
step2();
step3();
step4();
step5();
step6();
step7();
step8();
}
void step1(){
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(fast);
}
void step2(){
digitalWrite(in1, HIGH);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(fast);
}
void step3(){
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(fast);
}
void step4(){
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay(fast);
}
void step5(){
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay(fast);
}
void step6(){
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, HIGH);
delay(fast);
}
void step7(){
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(fast);
}
void step8(){
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(fast);
}
void off(){
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(Delay);
}