PLEASE HELP noob

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.

You are using code written for an old version (< 3.0) of the IRremote library. You can either change your code to work with the new version of the library, following the instructions that in the github page here or you can delete the new version of the IRremote library from your sketchbook/libraries folder and install an older version (2.x.x) and keep the code the way that it is. The older versions are available for install from the IDE library manager.

Read the forum guidelines to see how to properly post code and error messages.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

If you use the autoformat tool you will see where you have misplaced curly brackets ({}) and trying to define a function inside of a function.

The code that you posted is not the code that caused the errors that are included.

Here is your code properly posted in code tags and formatted. I put comments to show the misplaced and missing brackets.

//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
}  // ******************** this is out of place 
digitalWrite(pulPin, LOW);
inputA = digitalRead(switchA);
delay(1);
}
} // ***************** extra }

void goDown()
{
   digitalWrite(dirPin, HIGH); //DOWN

   void goUp() // ********** defining a function in a function, ILLEGAL
   {
      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);
         }
      }
// ***************** missing curly brackets.      

but a nice try :nerd_face:

That's a warning. You are using a function call from the older version of the library that may not work at all in future versions. The term "deprecated" means "You should not be using this function if you don't have to." The warning messages also tell you the NEW function you should be using.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.