My project is to move a stepper motor to control a variable capacitor and feedback info to an LCD.
I had just the basic multiple button switches to single pin working and had added some stepper motor movement to button 1 just a week ago. Today the previously working project fails. Updates to IDE impacted?
Assistance gratefully received.
Thanks
Nigel
My Code is
/-----( Import needed libraries )-----/
#include <Wire.h>
#include <LiquidCrystal_I2C.h> //Get this here https://arduino-info.wikispaces.com/LCD-Blue-I2C
#include <Stepper.h>
/-----( Declare Constants, Pin Numbers )-----/
#define STEPS_PER_MOTOR_REVOLUTION 32
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 64 //2048
/-----( Declare objects )-----/
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION,8,10,9,11); //Works both directions
// initialize the LCD library with the correct id
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // My I2C screen is on 0x3F - yours might not be. Check and adjust. Blue display
/-----( Declare Variables )-----/
int a=0;
int Steps2Take;
void setup() /----( SETUP: RUNS ONCE )----/
{
lcd.begin(20, 4);
pinMode(A1, INPUT_PULLUP); // sets analog pin for input
}
int readButtons(int pin)
// returns the button number pressed, or zero for none pressed
// int pin is the analog pin number to read
{
int b,c = 0;
c=analogRead(1); // get the analog value
if (c>1000)
{
b=0; // buttons have not been pressed
}
else
if (c>230 && c<250)
{
b=1; // button 1 pressed
}
else
if (c>195 && c<210)
{
b=2; // button 2 pressed
}
else
if (c>150 && c<170)
{
b=3; // button 3 pressed
}
else
if (c>110 && c<130)
{
b=4; // button 4 pressed
}
else
if (c>50 && c<80)
{
b=5; // button 4 pressed
}
else
if (c<20)
{
b=6; // button 5 pressed
}
return b;
}
void loop()
{
a=readButtons(5);
lcd.clear();
if (a==0) // no buttons pressed
{
lcd.setCursor(0,0);
lcd.print("Ready");
}
else
if (a==1) // someone pressed a button!
{
lcd.setCursor(0,1);
lcd.print("Pressed button ");
lcd.print(a);
lcd.setCursor(0,2);
lcd.print("Initialise running ");
Steps2Take = STEPS_PER_OUTPUT_REVOLUTION / 2; // Rotate CW 1/2 turn
small_stepper.setSpeed(700);
small_stepper.step(Steps2Take);
delay(1000);
Steps2Take = - STEPS_PER_OUTPUT_REVOLUTION / 2; // Rotate CCW 1/2 turn
small_stepper.setSpeed(700); // 700 a good max speed??
small_stepper.step(Steps2Take);
delay(8000);
lcd.setCursor(0,2);
lcd.print("Initialise Completed");
delay(5000);
}
else
if (a==2) // someone pressed a button!
{
lcd.setCursor(0,1);
lcd.print("Pressed button ");
lcd.print(a);
lcd.setCursor(0,2);
lcd.print("Tune UP ");
}
else
if (a==3) // someone pressed a button!
{
lcd.setCursor(0,1);
lcd.print("Pressed button ");
lcd.print(a);
lcd.setCursor(0,2);
lcd.print("Tune DOWN ");
}
else
if (a==4) // someone pressed a button!
{
lcd.setCursor(0,1);
lcd.print("Pressed button ");
lcd.print(a);
lcd.setCursor(0,2);
lcd.print("Tune 7.030 MHz ");
}
else
if (a==5) // someone pressed a button!
{
lcd.setCursor(0,1);
lcd.print("Pressed button ");
lcd.print(a);
lcd.setCursor(0,2);
lcd.print("Tune 10.030 MHz ");
}
else
if (a==6) // someone pressed a button!
{
lcd.setCursor(0,1);
lcd.print("Pressed button ");
lcd.print(a);
lcd.setCursor(0,2);
lcd.print("Tune 14.030 MHz ");
}
delay(1000); // give the human time to read LCD
}
Error message on compile is:-
Arduino: 1.6.7 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino:12:22: error: redefinition of 'Stepper small_stepper'
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION,8,10,9,11); //Works both directions
^
Loop_Tuner_Button_Test_Version_1.ino:12: error: 'Stepper small_stepper' previously declared here
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION,8,10,9,11); //Works both directions
^
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino:15:22: error: redefinition of 'LiquidCrystal_I2C lcd'
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // My I2C screen is on 0x3F - yours might not be. Check and adjust. Blue display
^
Loop_Tuner_Button_Test_Version_1.ino:15: error: 'LiquidCrystal_I2C lcd' previously declared here
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // My I2C screen is on 0x3F - yours might not be. Check and adjust. Blue display
^
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino:19:5: error: redefinition of 'int a'
int a=0;
^
Loop_Tuner_Button_Test_Version_1.ino:19: error: 'int a' previously defined here
int a=0;
^
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino:20:6: error: redefinition of 'int Steps2Take'
int Steps2Take;
^
Loop_Tuner_Button_Test_Version_1.ino:20: error: 'int Steps2Take' previously declared here
int Steps2Take;
^
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino: In function 'void setup()':
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino:23:6: error: redefinition of 'void setup()'
void setup() /----( SETUP: RUNS ONCE )----/
^
Loop_Tuner_Button_Test_Version_1.ino:23: error: 'void setup()' previously defined here
void setup() /----( SETUP: RUNS ONCE )----/
^
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino: In function 'int readButtons(int)':
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino:30:5: error: redefinition of 'int readButtons(int)'
int readButtons(int pin)
^
Loop_Tuner_Button_Test_Version_1.ino:30: error: 'int readButtons(int)' previously defined here
int readButtons(int pin)
^
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino: In function 'void loop()':
C:\Users\Nigel\Documents\Arduino\Loop_Tuner_Button_Test_Version_1\Loop_Tuner_Button_Test_Version_1.ino\Loop_Tuner_Button_Test_Version_1.ino - Backup.ino:73:6: error: redefinition of 'void loop()'
void loop()
^
Loop_Tuner_Button_Test_Version_1.ino:73: error: 'void loop()' previously defined here
void loop()
^
exit status 1
'Stepper small_stepper' previously declared here
Invalid library found in C:\Users\Nigel\Documents\Arduino\libraries\TFT_ILI9163C-master: C:\Users\Nigel\Documents\Arduino\libraries\TFT_ILI9163C-master
Invalid library found in C:\Users\Nigel\Documents\Arduino\libraries\TFT_ILI9163C-master: C:\Users\Nigel\Documents\Arduino\libraries\TFT_ILI9163C-master
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.