Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 1

Arduino project

Hi, I am working on a school project using an Arduino. my project has to do the following

1- move a stepper motor with some specifications, which I was able to manage by using an existing library.

2- Use push buttons to chose from different cases, and that where I am having trouble, I keep getting this message “’bp' was not declared in this scope”. But do not know how to fix it

3- The last part is I need to turn on a water pump that is connected to a relay module. The pump should pour water for a certain amount of time and stop, time should differ for each case, so I need one output going to the relay to do so.

Thanks :)

 

// defining buttons
int bp1 = 2;
int bp2 = 3;
int bp3 = 4;
/*
Stepper Motor Demonstration 1
Stepper-Demo1.ino
Demonstrates 28BYJ-48 Unipolar Stepper with ULN2003 Driver
Uses Arduino Stepper Library

DroneBot Workshop 2018
https://dronebotworkshop.com
*/

//Include the Arduino Stepper Library
#include <Stepper.h>

// Define Constants

// Number of steps per internal motor revolution
const float STEPS_PER_REV = 32;

// Amount of Gear Reduction
const float GEAR_RED = 64;

// Number of steps per geared output rotation
const float STEPS_PER_OUT_REV = STEPS_PER_REV * GEAR_RED;

// Define Variables

// Number of Steps Required
int StepsRequired;

// Create Instance of Stepper Class
// Specify Pins used for motor coils
// The pins used are 8,9,10,11
// Connected to ULN2003 Motor Driver In1, In2, In3, In4
// Pins entered in sequence 1-3-2-4 for proper step sequencing

Stepper steppermotor(STEPS_PER_REV, 8, 10, 9, 11);

void setup()
{
pinMode(bp1, INPUT);
pinMode(bp2, INPUT);
pinMode(bp3, INPUT);

}

void loop()
{
// Slow - 4-step CW sequence to observe lights on driver board
/*
steppermotor.setSpeed(1);
StepsRequired = 4;
steppermotor.step(StepsRequired);
delay(2000);
*/
//int dp =
switch (bp)
// Rotate CW 1/2 turn slowly
case 1:
{
StepsRequired = STEPS_PER_OUT_REV*2;
steppermotor.setSpeed(800);   
steppermotor.step(StepsRequired);
  
break;
}
  
case 2:
{
StepsRequired = - STEPS_PER_OUT_REV ;   
steppermotor.setSpeed(700);
steppermotor.step(StepsRequired);

break ;
}

case 3:
{
StepsRequired = - STEPS_PER_OUT_REV /2;   
steppermotor.setSpeed(700);
steppermotor.step(StepsRequired);

break ;
}
}