Hello peops,
I build the last couple of weeks A wireless communication between bluetooth on my android and my
bluetooth shield on the arduino uno R3. To use a button on my phone i could turn on a motor.
while my ''void loop'' function gets data from the bluetooth, i could easily turn on the motor with interrupts
The motor keeps spinning (clockwise) while i could recieve data from my blue (example to use other button
on my phone to spin the motor anti-clockwise) and i also let the RGB LED shine in colors i liked.
[bluetooth shield : https://iprototype.nl/products/arduino/shields/bluetooth-shield ]
Now i want to do it with some other components. I now have a motor shield
https://iprototype.nl/products/arduino/shields/arduino-motor-shield on the arduino uno R3
and i IR-remote
Gravity: IR Kit For Arduino - DFRobot
This is the following program for so far:
#include <Stepper.h>
#include "IRremote.h"
int recieve = 2;
IRrecv irrecv(recieve);
decode_results result;
#define EN1_PIN 3
#define DIR1_PIN 12
#define EN2_PIN 11
#define DIR2_PIN 13
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, DIR1_PIN, DIR2_PIN);
void setup() {
analogWrite(EN1_PIN, 255);
analogWrite(EN2_PIN, 255);
myStepper.setSpeed(150);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&result)){ //sensor ontvangt iets
translateIR();
irrecv.resume();
}
}
void translateIR()
{
switch(result.value){
case 0xFD00FF:
Serial.println("POWER ON");
myStepper.step(stepsPerRevolution);
break;
//more cases is unnecessary for now
}
} //everytime i have to use that ''power on'' button while it spins 1 or2 rotation and goes off
with interrupts i can do more things but the problem is now that interrupts or attachinterrupt
so far doesnt work like my other program some1 got a solution for me ????
Greetz Noddy1988