Incrementing Stepper.setSpeed value by holding down a button - Really stuck

So basically what the title says is my problem, I have a standby phase of the loop before the “if” statement. I want to hold down triggerButton1 to increment and loop the stepper.setSpeed, in turn accelerating the stepper to a limited speed. But I have warnings telling me…(see picture)

To give some insight of my project after that point:

once i have some sort of speed control, at the same time my led strip cylon mode need to sync its speed with the speed of the motor as it speeds up. Once it reaches a desired speed of 200, the lcd will say “fire!” you then click the fireButton2 and a burst of light flashes and the heatVents open and close rapidly. A temperature sensor on the back of the stepper is monitored and gives it a scale of safe and dangerous temperatures; if it gets too hot the stepper stops, the heatVents open and wait to cool down before returning to the standby phase. That’s what i have left to code and could use some help please!

#include <Servo.h>
#include <LiquidCrystal.h>
#include “FastLED.h”
#define PIN 9
#define STEPS 200
#define NUM_LEDS_PER_STRIP 35
CRGB redLeds[NUM_LEDS_PER_STRIP];
CRGB tealLeds[NUM_LEDS_PER_STRIP];

/*
JM-92 Pulse Cannon Mk I
by Jordan
2015

The brains and operations of the arm cannon
*/
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
const int analogTemp = A1; // Motor temperature
int triggerButton1 = 28; // Button that starts the cannon charging and barrel rotation
int fireButton2 = 30; // Button that fires a shot
const int elwireRelay = 24; // Electroluminesent Wire
const float baselineTemp = 20.0; // Ambient temp
int speedVal; // how fast the stepper should accelerate
int switchState = 1;
int pos = 0; // variable to store the servo position
Servo heatVent; // Allows heat to escape, Changed to pin 7 from pin 4
Stepper stepper(STEPS, 9, 8, 7, 6);
LiquidCrystal lcd(2, 3, 4, 5, 11, 12);

void setup() {
// put your setup code here, to run once:
// tell FastLED there’s 60 NEOPIXEL leds on pin 10
FastLED.addLeds<NEOPIXEL, 22>(redLeds, NUM_LEDS_PER_STRIP);

// tell FastLED there’s 60 NEOPIXEL leds on pin 11
FastLED.addLeds<NEOPIXEL, 26>(tealLeds, NUM_LEDS_PER_STRIP);

heatVent.attach(32);

pinMode(analogTemp, OUTPUT);
pinMode(elwireRelay, OUTPUT);
pinMode(triggerButton1, INPUT);
pinMode(fireButton2, INPUT);
//Declare which pins are what^
//Start up of Pulse Cannon
delay(1000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(“Pulse Cannon MKI”);
lcd.setCursor(0, 1);
lcd.print(“Online”);
delay(5000);
lcd.clear();
lcd.print(“Running”);
lcd.setCursor(0, 1);
lcd.print(“Diagnostics”);
delay(2000);
lcd.clear();
lcd.print(“Please Stand By”);
// Start of component run through/Check.
digitalWrite(elwireRelay, HIGH);
delay(2000);
digitalWrite(elwireRelay, LOW);
delay(2000);
// Servo Initiate: Need to install flaps to calibrate
for (pos = 0; pos <= 180; pos += 10) // goes from 0 degrees to 180 degrees
// in steps of 1 degree
heatVent.write(pos); // tell servo to go to position in variable ‘pos’
delay(2000); // waits 15ms for the servo to reach the position
for (pos = 180; pos >= 0; pos -= 10) // goes from 180 degrees to 0 degrees
heatVent.write(pos); // tell servo to go to position in variable ‘pos’
delay(2000);
// set the speed of the motor to 30 RPMs
stepper.setSpeed(100);
stepper.step(STEPS);
delay(2000);
stepper.step(-STEPS);
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.println(“Diagnostics”);
lcd.setCursor(0, 2);
lcd.println(“Complete!”);
delay(3000);
lcd.clear();

}

void loop() {

// Standby LED animation
for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
// set our current dot to red, green, and blue
redLeds = CRGB::Teal;
_ tealLeds = CRGB::Teal;_
* FastLED.show();*
* // clear our current dot before we move on*
_ redLeds = CRGB::Black;
tealLeds = CRGB::Black;
* delay(100);
//Showing how the cannon gets its energy somehow.
digitalWrite(elwireRelay, HIGH); //Showing how the cannon gets its energy somehow.
// This is the standby block: LED circles around the cannon and up and down, Temperature will be taken all the time*

* // We now wait for the user to click the charge button.
int sensorVal = analogRead(analogTemp); //Main standby mode when the user isnt doing anything.
lcd.setCursor(0, 0);
lcd.print(“Ready!”);
lcd.setCursor(0, 1);
lcd.print(“Core Temp is:”);
lcd.print(sensorVal);*

float voltage = (sensorVal / 1024.0) * 5.0;
float temperature = (voltage - .5) * 100;_

* if (digitalRead(triggerButton1) == HIGH) {*
* stepper.setSpeed(0);*
* stepper.step(STEPS);*
* long speedVal = stepper.setSpeed();*
* {*
* }*
* }*
* }*

The error mean:

  • Count your brackets. Each time you see a {, add 1, and each time you see a }, substract 1. At the end, the result must be 0.

  • There is no such function stepper.setSpeed();

  • There is no such function stepper.setSpeed();

My version of the Stepper class has a setSpeed() method.

Of course, OP is not including Stepper.h, so the Stepper class isn't available, and the Stepper instance can't be created.

@Muteon,

If you take the trouble to modify your original post to put your long code between code tags so it looks like this I will take the trouble to study it. Not otherwise.

…R

#include <Servo.h>
#include <LiquidCrystal.h>
#include "FastLED.h"
#define PIN            9
#define STEPS 200
#define NUM_LEDS_PER_STRIP 35
CRGB redLeds[NUM_LEDS_PER_STRIP];
CRGB tealLeds[NUM_LEDS_PER_STRIP];

/*
JM-92 Pulse Cannon Mk I
by Jordan 
2015

The brains and operations of the arm cannon
*/
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
const int analogTemp = A1; // Motor temperature
int triggerButton1 = 28; // Button that starts the cannon charging and barrel rotation
int fireButton2 = 30; // Button that fires a shot
const int elwireRelay = 24; // Electroluminesent Wire
const float baselineTemp = 20.0; // Ambient temp
int speedVal; // how fast the stepper should accelerate
int switchState = 1;
int pos = 0;    // variable to store the servo position
Servo heatVent; // Allows heat to escape, Changed to pin 7 from pin 4
Stepper stepper(STEPS, 9, 8, 7, 6);
LiquidCrystal lcd(2, 3, 4, 5, 11, 12);

void setup() {
 // put your setup code here, to run once:
 // tell FastLED there's 60 NEOPIXEL leds on pin 10
 FastLED.addLeds<NEOPIXEL, 22>(redLeds, NUM_LEDS_PER_STRIP);

 // tell FastLED there's 60 NEOPIXEL leds on pin 11
 FastLED.addLeds<NEOPIXEL, 26>(tealLeds, NUM_LEDS_PER_STRIP);


 heatVent.attach(32);


 pinMode(analogTemp, OUTPUT);
 pinMode(elwireRelay, OUTPUT);
 pinMode(triggerButton1, INPUT);
 pinMode(fireButton2, INPUT);
 //Declare which pins are what^
 //Start up of Pulse Cannon
 delay(1000);
 lcd.begin(16, 2);
 lcd.setCursor(0, 0);
 lcd.print("Pulse Cannon MKI");
 lcd.setCursor(0, 1);
 lcd.print("Online");
 delay(5000);
 lcd.clear();
 lcd.print("Running");
 lcd.setCursor(0, 1);
 lcd.print("Diagnostics");
 delay(2000);
 lcd.clear();
 lcd.print("Please Stand By");
 // Start of component run through/Check.
 digitalWrite(elwireRelay, HIGH);
 delay(2000);
 digitalWrite(elwireRelay, LOW);
 delay(2000);
 // Servo Initiate: Need to install flaps to calibrate
 for (pos = 0; pos <= 180; pos += 10) // goes from 0 degrees to 180 degrees
   // in steps of 1 degree
   heatVent.write(pos);              // tell servo to go to position in variable 'pos'
 delay(2000);                       // waits 15ms for the servo to reach the position
 for (pos = 180; pos >= 0; pos -= 10) // goes from 180 degrees to 0 degrees
   heatVent.write(pos);              // tell servo to go to position in variable 'pos'
 delay(2000);
 // set the speed of the motor to 30 RPMs
 stepper.setSpeed(100);
 stepper.step(STEPS);
 delay(2000);
 stepper.step(-STEPS);
 delay(2000);
 lcd.clear();
 lcd.setCursor(0, 0);
 lcd.println("Diagnostics");
 lcd.setCursor(0, 2);
 lcd.println("Complete!");
 delay(3000);
 lcd.clear();


}

void loop() {

 // Standby LED animation
 for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
   // set our current dot to red, green, and blue
   redLeds[i] = CRGB::Teal;
   tealLeds[i] = CRGB::Teal;
   FastLED.show();
   // clear our current dot before we move on
   redLeds[i] = CRGB::Black;
   tealLeds[i] = CRGB::Black;
   delay(100);

   //Showing how the cannon gets its energy somehow.
   digitalWrite(elwireRelay, HIGH); //Showing how the cannon gets its energy somehow.

   // This is the standby block: LED circles around the cannon and up and down, Temperature will be taken all the time
   // We now wait for the user to click the charge button.

   int sensorVal = analogRead(analogTemp); //Main standby mode when the user isnt doing anything.
   lcd.setCursor(0, 0);
   lcd.print("Ready!");
   lcd.setCursor(0, 1);
   lcd.print("Core Temp is:");
   lcd.print(sensorVal);
   float voltage = (sensorVal / 1024.0) * 5.0;
   float temperature = (voltage - .5) * 100;
   

   if (digitalRead(triggerButton1) == HIGH) {
     stepper.setSpeed(0);
     stepper.step(STEPS);
     long speedVal = stepper.setSpeed();
     {




     }
   }
 }

Did you have a question?

What is a "pulse cannon" ?

...R

Pulse Cannon is my project name for college. My question is only how to increment speed with a NEMA 17 12V stepper motor using the Adafruit TB6612 1.2A DC/Stepper Motor Driver Breakout Board, the sample code they give is simple and easy to use. At the same time using 60 LED RGB Strip and the FastLED library to match its color changing speed with the motors.

If you are not going to tell me what a "pulse cannon" is I am not going to help.

...R

My question is only how to increment speed with a NEMA 17 12V stepper motor using the Adafruit TB6612 1.2A DC/Stepper Motor Driver Breakout Board, the sample code they give is simple and easy to use.

 stepper.setSpeed(100);
 stepper.step(STEPS);

What speed does the stepper step at? What speed do you want it to step at? How are you powering the stepper driver?

@Robin

If you are familiar with Megaman or Metroid, I've designed and 3D printed my own adaptation of a wearable arm cannon aka: Pulse Cannon MKI

@PaulS

The motor is a 200 step motor, I don't have a tachometer to tell you its max speed but I want the setSpeed to start at (0) then increment by 10 until my target speed is (200) and the stepper is being powered with a variable DC power supply at 12V.

   if (digitalRead(triggerButton1) == HIGH) {
     stepper.setSpeed(0);
     stepper.step(STEPS);

At that speed, I can imagine that the step() method will take a while to return.

     long speedVal = stepper.setSpeed();

Does this even compile? The setSpeed() method has only one definition. It takes an argument and does not return a value.

     {




     }

WTF?

Where are you calling setSpeed() with a different value? Where are you recording the value that you last called setSpeed() with? Where are you incrementing that value? How often should that value be incremented, while the switch is held?

Why are you blocking, waiting for steps to be taken every time you screw up the speed?

Until you have some firm requirements, you are pissing into the wind. Pull your zipper up.

Muteon:
If you are familiar with Megaman or Metroid, I've designed and 3D printed my own adaptation of a wearable arm cannon aka: Pulse Cannon MKI

I am not.

But I presume it is some sort of shoot-em-up game and I don't believe in encouraging that sort of thing. There is altogther too much violence in the world - and it seems to be getting worse by the day.

...R

Robin2:
I am not.

But I presume it is some sort of shoot-em-up game and I don’t believe in encouraging that sort of thing. There is altogther too much violence in the world - and it seems to be getting worse by the day.

…R

Most studies conclude that global violence is actually on the decline, at least per capita if not in absolute terms, and “youth violence” in the US has dropped in absolute terms between 1996 and 2014 even as video game sales has increased.

Yes, even “mass shootings” that we’ve all been hearing about lately have been in decline since the 20th century, despite the fear-mongers doing their best to portray them as if they were on the increase.

The world is a much safer place to live now than it was 100, or even 50, years ago.

christop:
The world is a much safer place to live now than it was 100, or even 50, years ago.

Maybe.

But is it safer than last year or the year before.
The Turkish Govt has just started shooting at people.
The UK and US Govts (both of which claim to be paragons of democracy) seem to prefer shooting at people rather than trying to understand their problems. And both countries have recent history to show the futility of that approach.

There are many more people on earth than there were even 50 years ago. And with scarce resources there will be a great temptation to grab what you can at the point of a gun. That is not the sort of solution I want to encourage.

The only reason for guns (or any weapon) is to force someone to do something s/he does not wish to do.

...R