Hi All, I'm new to the wonderful world of Arduino and C++ so please be gentle with me. I have been searching the internet for days and can't find the answer to my question.
I am wanting to control just the speed of a stepper motor via Bluetooth. I have vast experience with steppers and drivers and have it all connected up properly. Using a simple code (accellstepper lib)) I can control the speed with a 10k Pot no problem.
I have used a few bits of code that I have found online and can get the stepper to start and stop via my HC-06 Bluetooth module by issuing commands from an android terminal app.
But I am struggling to get any of the code to work using a slider built in MIT,
here is the first code that i can use with blutooth terminal on Android
#include <AccelStepper.h> // Library created by Mike McCauley at http://www.airspayce.com/mikem/arduino/AccelStepper/
// AccelStepper Setup
AccelStepper stepper(1, 8, 9); // 1 = Easy Driver interface, Pin 4 connected to STEP pin of Easy Driver, Pin 5 connected to DIR pin of Easy Driver
#include <SoftwareSerial.h>
SoftwareSerial portOne(0, 1); // software serial #1: TX = digital pin 10, RX = digital pin 11
// Define our three input button pins
#define button1 3
#define button2 2
int spd = 3000; // The current speed in steps/second
int sign = 0; // Either 1, 0 or -1
void setup()
{
Serial.begin(9600);
stepper.setMaxSpeed(3000);
stepper.setSpeed(1000);
// Set up the three button inputs, with pullups
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
}
void loop()
{
char c;
if(Serial.available()) {
c = Serial.read();
if (c == 'f') { // forward
sign = 1;
}
if (c == 'r') { // reverse
sign = -1;
}
if (c == 's') { // stop
sign = 0;
}
if (c == '1') { // super slow
spd = 10;
}
if (c == '2') { // slow
spd = 100;
}
if (c == '3') { // medium
spd = 300;
}
if (c == '4') { // fast
spd = 500;
}
if (c == '5') { // faster
spd = 700;
}
if (c == '6') { // superfast
spd = 3000;
}
}
if (digitalRead(button1) == 0) {
sign = 1;
}
else if (digitalRead(button2) == 0) {
sign = -1;
}
stepper.setSpeed(sign * spd);
stepper.runSpeed();
}
This code was taken from the net. I can get it to start and stop with terminal commands but not using a slider. Any help would be muchly appreciated! Im even willing to pay for someone's time.
Functions I want is Control Speed using slider on android and Estop button.