Go Down

Topic: Irremote problem (Read 10264 times) previous topic - next topic

kamokaki

Jan 22, 2014, 03:45 pm Last Edit: Jan 25, 2014, 11:51 pm by kamokaki Reason: 1
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.


Code: [Select]
#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.

Msquare

"funkar inte" - du får fel i kompilering eller Serial siger rigtigt värde men servoen rör sig inte eller vad ?

Beskriv hvad du hoppas skal hända och vad som faktisk händer

Erni

@kamokaki

Det er ikke populært at stille samme spørgsmål i flere sub-fora

http://forum.arduino.cc/index.php?topic=212568.msg1557980#msg1557980

AWOL

#3
Jan 25, 2014, 11:01 pm Last Edit: Jan 25, 2014, 11:03 pm by AWOL Reason: 1
1) code tags. Use them
2) auto format. Use it.
3) serial debug output. Post it.
4) cross post. Don't do it.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

kamokaki

Im sorry but I dont really undestand.. I found most of the code online so can you somhow answer easier in a way someone new would understand.

kamokaki

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.

AWOL

Quote
I dont really undestand

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?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

kamokaki

ohh ok. cross post. I did one because its a scandinavian so people reading there could help me out.

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

UKHeliBob

What does happen when you run the program ?
Where does the servo get its power from ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

kamokaki

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.

AWOL

What I've been trying to explain is we can't see what you you can see.
Good luck.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up