hello, im new to arduino and any type of programing. after weeks of reading and watching guides iv managed to get my code working but still getting errors and cant figure out how to fix. my stepper motor goes up and stops when limit switch is pressed but will not come down. any help would be much appreciated. here is my code and errors. thanks
//IR Remote
#include <IRremote.h>
int IR_Recv = 11; //IR Receiver on Pin 11
IRrecv irrecv(IR_Recv); //Initialise IR receiver
decode_results results;
//Stepper
const int pulPin = 10; //Pulse pin at Arduino pin 10
const int dirPin = 9; //Direction pin at Arduino pin 9
const int enblPin = 12; //Enable pin at Arduino pin 12
//const int speedS = 20; //Define speed of stepper (1 is higher speed than 10) should not be less than 20
//Limit switch
const int switchA = 6; //Upper limit switch at pin 6
const int switchB = 7; //Bottom limit switch at pin 7
int inputA = 0; //Store button A data
int inputB = 0; //Store button B data
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //Start serial communication at 9600 bauds
irrecv.enableIRIn(); //Starts the receiver
//Stepper
pinMode(pulPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(enblPin, OUTPUT);
digitalWrite(enblPin, LOW); //Enable the Stepper
//Limit switch
pinMode(switchA, INPUT); //Input A
pinMode(switchB, INPUT); //Input B
}
void loop() {
// put your main code here, to run repeatedly:
if (irrecv.decode(&results)) { //If data received from remote
Serial.println(results.value);
if (results.value == 3772834333) { //DOWN
Serial.println("GOING DOWN");
goDown();
}
if (results.value == 3772797613) { //UP
Serial.println("GOING UP");
goUp();
}
irrecv.resume();
}
delay(10); //Delay of 10ms to avoid errors
}
digitalWrite(pulPin, LOW);
inputA = digitalRead(switchA);
delay(1);
}
}
void goDown() {
digitalWrite(dirPin, HIGH); //DOWN
void goUp() {
digitalWrite(dirPin, LOW); //UP
inputA = digitalRead(switchA); //Check upper limit switch
while (inputA == HIGH) { //Limit switch not pressed
digitalWrite(pulPin, HIGH);
delay(1);
inputB = digitalRead(switchB); //Check bottom limit switch
while (inputB == HIGH) { //Limit switch not pressed
digitalWrite(pulPin, HIGH);
delay(1);
digitalWrite(pulPin, LOW);
inputB = digitalRead(switchB);
delay(1);
}
}
C:\Users\embre\AppData\Local\Temp\Speed_IR_Receive\Speed_IR_Receive.ino: In function 'void loop()':
C:\Users\embre\AppData\Local\Temp\Speed_IR_Receive\Speed_IR_Receive.ino:33:29: warning: 'bool IRrecv::decode(decode_results*)' is deprecated: Please use IrReceiver.decode() without a parameter and IrReceiver.decodedIRData. . [-Wdeprecated-declarations]
if (irrecv.decode(&results)) { //If data received from remote
^
In file included from C:\Users\embre\OneDrive\Documents\Arduino\libraries\IRremote\src/IRremote.h:188:0,
from C:\Users\embre\AppData\Local\Temp\Speed_IR_Receive\Speed_IR_Receive.ino:2:
C:\Users\embre\OneDrive\Documents\Arduino\libraries\IRremote\src/IRReceive.cpp.h:1373:6: note: declared here
bool IRrecv::decode(decode_results *aResults) {
^~~~~~
Sketch uses 6024 bytes (18%) of program storage space. Maximum is 32256 bytes.
Global variables use 657 bytes (32%) of dynamic memory, leaving 1391 bytes for local variables. Maximum is 2048 bytes.