This is what I'm trying to do. I don't want to input the same command twice so I am trying make it so I can't. Here's my messed up code. Please help.
#include "Stepper.h"
#include "IRremote.h"
/----- Variables, Pins -----/
#define STEPS 32 // Number of steps per revolution of Internal shaft
int Steps2Take; // 2048 = 1 Revolution
int receiver = 12; // Signal Pin of IR receiver to Arduino Digital Pin 6
int lastCommand=0;
/-----( Declare objects )-----/
// Setup of proper sequencing for Motor Driver Pins
// In1, In2, In3, In4 in the sequence 1-3-2-4
Stepper small_stepper(STEPS, 8, 10, 9, 11);
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
void setup()
{
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
switch(results.value)
{
case 1: 0xFFA857:; // VOL+ button pressed
check; if (lastCommand==1);
small_stepper.setSpeed(500); //Max seems to be 500
Steps2Take = 512; // Rotate CW
small_stepper.step(Steps2Take);
delay(2000);
lastCommand=1;
break;
{
case 2: 0xFF629D: ; // VOL- button pressed
check if (lastCommand==2);
small_stepper.setSpeed(500);
Steps2Take = -512; // Rotate CCW
small_stepper.step(Steps2Take);
delay(2000);
(lastCommand=2);
break;
}
}
irrecv.resume(); // receive the next value
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
}/* --end main loop -- */
ERROR CODES
Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\name\AppData\Local\Temp\arduino_modified_sketch_950187\With_Remote.ino: In
function 'void loop()':
With_Remote:35: error: expected ';' before ':' token
case 1: 0xFFA857:; // VOL+ button pressed
^
With_Remote:36: error: 'check' was not declared in this scope
check; if (lastCommand==1);
^
With_Remote:47: error: expected ';' before ':' token
case 2: 0xFF629D: ; // VOL- button pressed
^
With_Remote:49: error: expected ';' before 'if'
check if (lastCommand==2);
^
Multiple libraries were found for "IRremote.h"
Used: C:\Users\Sevveek\Documents\Arduino\libraries\IRremote
Not used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote
exit status 1
expected ';' before ':' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.