Tjena, försöker lösa problemet med att använda en ir controll för att styra servo. Använder en arduino uno rev 3
detta är vad jag gjort.
#include <Servo.h>
#include <IRremote.h>
unsigned long Value1 = 0xFFA25D; // where XXXXXXXX is on our your remote's values
unsigned long Value2 = 0xFF629D; // where XXXXXXXX is another button on your remote
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
Servo servo1;
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
// initialize the digital pin as an output.
servo1.attach(10); // attack servo to digital pin 10
}
// the loop routine runs over and over again forever:
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
if(results.value == Value1) {
servo1.write(160);
}
else if (results.value == Value2){
servo1.write(75);
}
}
Jag vill kunna få hjälp med att förstå vart koderna man får av IR recivern ska in.
tacksam för all svar.
Vad jag inte förstår är vart man ska sätta in värdet man får när man trycker på kontrollen och får koderna den ger av.
Anledningen till att jag skrev två olika forum är att det kanske bli enklare att förstå det på svenska då jag är en nybörjare.
Use code tags. It avoids the possibility of the forum mangling your code.
Use auto format. It makes you code easier to read.
You have debug prints in your code. Show us the output.
Don't cross-post. What more can I say?
Well the servo is attached to the 5v output. Its a rather small servo that you get in a arduino kit.
Then i also have a reciver and a tiny remote included.
I have downloaded the IRREMOTE file from ken shiriff blog witch enables me to connect the reciver and type in the buttons to get the codes and raw from it.
What Ive been trying to explain is that I want to move the servo from a sertain degree to another by pressing the remote.