Hmm, I posted the incorrect code at the top of this thread. The correct code is below:
/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // includes the LCD display binaries
#include <Stepper.h> // includes the stepper motor binaries
/*-----( Declare objects )-----*/
// LCD display
// set the LCD address to 0x27 for a 16 chars 2 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address to 0x27
// Stepper motor
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution for your motor
Stepper myStepper(stepsPerRevolution, 8,9); // initialize the stepper library on pins 8 through 9
/*-----( End objects )-----*/
/*-----( Declare Variables )-----*/
int val = 0;
/*-----( End Variables )-----*/
/*----( SETUP: RUNS ONCE )----*/
void setup()
{
myStepper.setSpeed(200); // set the speed at 60 rpm:
Serial.begin(9600); // initialize the serial port:
lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines and turn on backlight
// NOTE: Cursor Position: (CHAR, LINE) start at 0
lcd.setCursor(4,0); //Start at character 4 on line 0
lcd.print("Booting");
lcd.setCursor(2,1); //Start at character 4 on line 0
lcd.print("Please Wait");
delay(3000);
}
/*--(end setup )---*/
/*----( LOOP: RUNS CONSTANTLY )----*/
void loop()
{
Serial.println("Running");
val = analogRead(2); // read potenttiometer data from analogue pin 2
Serial.println(val); // print the resistor value to the serial window
int pause = val*10; // set the value of the pause variable by mulitiplying the pot value x 10 to increase time range
Serial.println(pause/1000); // 1000 is 1 second
lcd.clear(); // clear lcd screen
lcd.setCursor(1,0); // set position of text displayed on the LCD pannel (location is cursor position, line) on top line
lcd.print("Time in flame:"); // top line text
lcd.setCursor(2,1); // set position of variable text displayed on the LCD pannel bottom line
lcd.print(pause/1000); // delay in seconds
lcd.setCursor(6,1); // set position of text displayed on the LCD pannel bottom line after the variable
lcd.print("seconds"); // text after the delay variable on the bottom line
myStepper.step(1280); // perform one step with motor
delay(pause); // pause motor for x number of seconds (from variable resistor read value)
}
/* --(end main loop )-- */
/* ( THE END ) */
So.. if I wanted to achieve a smooth control I would use:
LCD connections:
GND - Ground
VCC - +5v
SDA - Analogue pin 4
SCL - Analogue pin 5
/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // includes the LCD display binaries
#include <Stepper.h> // includes the stepper motor binaries
/*-----( Declare objects )-----*/
// LCD display
// set the LCD address to 0x27 for a 16 chars 2 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address to 0x27
// Stepper motor
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution for your motor
Stepper myStepper(stepsPerRevolution, 8,9); // initialize the stepper library on pins 8 through 9
/*-----( End objects )-----*/
/*-----( Declare Variables )-----*/
int val = 0;
/*-----( End Variables )-----*/
/*----( SETUP: RUNS ONCE )----*/
void setup()
{
myStepper.setSpeed(200); // set the speed at 60 rpm:
Serial.begin(9600); // initialize the serial port:
lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines and turn on backlight
// NOTE: Cursor Position: (CHAR, LINE) start at 0
lcd.setCursor(4,0); //Start at character 4 on line 0
lcd.print("Booting");
lcd.setCursor(2,1); //Start at character 4 on line 0
lcd.print("Please Wait");
delay(3000);
}
/*--(end setup )---*/
/*----( LOOP: RUNS CONSTANTLY )----*/
int minDelay = 1000;
int maxDelay = 10000;
void loop()
{
Serial.println("Running");
val = analogRead(2); // read potenttiometer data from analogue pin 2
Serial.println(val); // print the resistor value to the serial window
int pause = map(val, 0, 1023, minDelay, maxDelay); // set the value of the pause variable
Serial.println(pause/1000); // 1000 is 1 second
lcd.clear(); // clear lcd screen
lcd.setCursor(1,0); // set position of text displayed on the LCD pannel (location is cursor position, line) on top line
lcd.print("Time in flame:"); // top line text
lcd.setCursor(2,1); // set position of variable text displayed on the LCD pannel bottom line
lcd.print(pause/1000); // delay in seconds
lcd.setCursor(6,1); // set position of text displayed on the LCD pannel bottom line after the variable
lcd.print("seconds"); // text after the delay variable on the bottom line
myStepper.step(1280); // perform one step with motor
delay(pause); // pause motor for x number of seconds (from variable resistor read value)
}
/* --(end main loop )-- */
/* ( THE END ) */
What would I need to change to create the half second steps as I originally wanted?