#include <RCSwitch.h>
#include <AccelStepper.h>
// Button definitions
#define D3_ON 5246997
#define D3_OFF 5246996
// Arduino pin definitions
#define ENDSWITCHL 4 // Endswitch Left
#define ENDSWITCHR 5 // Endswitch Right
#define LED_PIN 13
#define RECEIVERPIN 0
// Stepper data
#define SPEED 500
#define LEFT -1
#define RIGHT 1
#define STOP 0
// NOTE: The sequence 8-10-9-11 is required for proper sequencing of 28BYJ48. The leading '4' is half-step mode (4-wire)
AccelStepper stepper(4, 8, 10, 9, 11);
// classses
RCSwitch rfSwitch = RCSwitch(); // 434 receiver & transmitter
// Global Variables
unsigned long value;
void setup() {
pinMode(ENDSWITCHL, INPUT_PULLUP);
pinMode(ENDSWITCHR, INPUT_PULLUP);
stepper.setMaxSpeed(SPEED);
stepper.setSpeed(SPEED);
Serial.begin(115200);
// 434 receiver on interrupt #0 (pin #2)
rfSwitch.enableReceive(RECEIVERPIN);
Serial.println("[+] Listening");
}
int dir = STOP;
void loop() {
if (rfSwitch.available()) {
value = rfSwitch.getReceivedValue();
rfSwitch.resetAvailable();
switch (value) {
digitalWrite(LED_PIN, true);
case D3_ON:
digitalWrite(LED_PIN, true);
switch (dir) {
case LEFT: dir = STOP; stepper.disableOutputs(); break;
case STOP: dir = LEFT; break;
}
break;
case D3_OFF:
digitalWrite(LED_PIN, true);
switch (dir) {
case RIGHT: dir = STOP; stepper.disableOutputs(); break;
case STOP: dir = RIGHT; break;
}
break;
}
digitalWrite(LED_PIN, false);
}
// Some final fysical security measures to prevent de mechanics to crash
if ((digitalRead(ENDSWITCHL) == LOW) && (dir == LEFT)) {
dir = STOP;
stepper.disableOutputs();
Serial.println("STOP BY ENDSWITCH LEFT");
}
if ((digitalRead(ENDSWITCHR) == LOW) && (dir == RIGHT)) {
dir = STOP;
stepper.disableOutputs();
Serial.println("STOP BY ENDSWITCH RIGHT");
}
stepper.setSpeed(SPEED * dir);
stepper.run();
}
--
You received this message because you are subscribed to a topic in the Google Groups "accelstepper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/accelstepper/37KgKoXhwwU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
> > > > > > > > > > accels...@googlegroups.com.
> > > > > > > > > > For more options, visit https://groups.google.com/d/optout
> >
> > .
> >
> > > > > > > > --
> > > > > > > > Mike McCauley VK4AMM
> > > >
> > > > mi...@airspayce.com
> > > >
> > > > > > > > Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223
> > > >
> > > > Australia
> > > >
> > > > > > > > http://www.airspayce.com
> > > > > > > > Phone +61 7 5598-7474
> > > > > > > >
> > > > > > > > --
> > > > > > > > You received this message because you are subscribed to a
> >
> > topic in
> >
> > > > the
> > > >
> > > > > > > > Google Groups "accelstepper" group.
> > > > > > > > To unsubscribe from this topic, visit
> > > >
> > > > https://groups.google.com/d/topic/accelstepper/37KgKoXhwwU/unsubscribe
> > > >
> > > > > > .
> > > > > >
> > > > > > > > To unsubscribe from this group and all its topics, send an
> >
> >
> > > > > > > > to
> > > > > > > > accels...@googlegroups.com.
> > > > > > > > For more options, visit https://groups.google.com/d/optout.
> > > > > >
> > > > > > --
> > > > > > Mike McCauley VK4AMM
> >
> > mi...@airspayce.com
> >
> > > > > > Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223
> >
> > Australia
> >
> > > > > > http://www.airspayce.com
> > > > > > Phone +61 7 5598-7474
> > > > > >
> > > > > > --
> > > > > > You received this message because you are subscribed to a topic in
> >
> > the
> >
> > > > > > Google Groups "accelstepper" group.
> > > > > > To unsubscribe from this topic, visit
> >
> > https://groups.google.com/d/topic/accelstepper/37KgKoXhwwU/unsubscribe
> >
> > > > .
> > > >
> > > > > > To unsubscribe from this group and all its topics, send an email
> > > > > > to
> > > > > > accels...@googlegroups.com.
> > > > > > For more options, visit https://groups.google.com/d/optout.
> > > >
> > > > --
> > > > Mike McCauley VK4AMM mi...@airspayce.com
> > > > Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
> > > > http://www.airspayce.com
> > > > Phone +61 7 5598-7474
> > > >
> > > > --
> > > > You received this message because you are subscribed to a topic in the
> > > > Google Groups "accelstepper" group.
> > > > To unsubscribe from this topic, visit
> > > > https://groups.google.com/d/topic/accelstepper/37KgKoXhwwU/unsubscribe
> >
> > .
> >
> > > > To unsubscribe from this group and all its topics, send an email to
> > > > accels...@googlegroups.com.
> > > > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > Mike McCauley VK4AMM mi...@airspayce.com
> > Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
> > http://www.airspayce.com
> > Phone +61 7 5598-7474
> >
> > --
> > You received this message because you are subscribed to a topic in the
> > Google Groups "accelstepper" group.
> > To unsubscribe from this topic, visit
> > https://groups.google.com/d/topic/accelstepper/37KgKoXhwwU/unsubscribe.
> > To unsubscribe from this group and all its topics, send an email to
> > For more options, visit https://groups.google.com/d/optout.
--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com
Phone +61 7 5598-7474
--
You received this message because you are subscribed to a topic in the Google Groups "accelstepper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/accelstepper/37KgKoXhwwU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to accels...@googlegroups.com.