Remote control + Servo

i try to use an remote contrl to control my servo but nothing happens with this code
can somebody help me and correct this code

#include <IRremote.h>
#include <Servo.h>

Servo motor1;

const int RECV_PIN = 4;

int togglestate = 0;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
motor1.attach(11);

}

void loop(){

if (irrecv.decode(&results))

switch(results.value){
case 0xFFA25D:
{

motor1.write(0);
delay(10000);
motor1.write(180);
break;

}
irrecv.resume();
}
}
:slight_smile:

Setze Deinen Code bitte in Codetags (</>-Button oben links im Forumseditor oder [code] davor und [/code] dahinter ohne *).
Dann ist er auch auf mobilen Geräten besser lesbar.
Das kannst Du auch noch nachträglich ändern.

Außerdem entferne bitte die unnötigen Leerzeilem und formatiere den Code ordentlich (+T in der IDE hilft Dir dabei).

Gruß Tommy

Well, thats very easy.

Just look THIS video until its end and everything is clear.

It helped me in a good way that exact the result you are looking for.

Maybe your IR transmitter has ( as mine does also ) a different repeat code. That is not so easy to handle.

But, before we guess and guess, just have a youtube session, and you will find out what you need.
Basically your 10000 delay is awfull.
there are better ways to do that.
Have a look to blinkwithoutdelay.
Learn millis.

so ?
geht aber leider noch nicht

#include <IRremote.h>
#include <Servo.h>

Servo motor1;

const int RECV_PIN = 4;

int togglestate = 0;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
motor1.attach(11);

}

void loop(){

if (irrecv.decode(&results))

switch(results.value){
case 0xFF906F :Serial.println("UP");

motor1.write(0);
break;

case 0xFFE01F:Serial.println("Down");
motor1.write(180);
break;

irrecv.resume();
}
}

Tommy56:
Setze Deinen Code bitte in Codetags (</>-Button oben links im Forumseditor oder [code] davor und [/code] dahinter ohne *).
Dann ist er auch auf mobilen Geräten besser lesbar.
Das kannst Du auch noch nachträglich ändern.

Außerdem entferne bitte die unnötigen Leerzeilem und formatiere den Code ordentlich (+T in der IDE hilft Dir dabei).

Gruß Tommy

janeden:
so ?
geht aber leider noch nicht

Warum beherzigst Du den Hinweis von Tommy nicht?

#include <IRremote.h>
#include <Servo.h>

Servo motor1;
const int RECV_PIN = 4;
int togglestate = 0;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  motor1.attach(11);
}

void loop() {
  if (irrecv.decode(&results)) {
    switch (results.value) {
      case 0xFF906F:
        Serial.println("UP");
        motor1.write(0);
        break;
      case 0xFFE01F:
        Serial.println("Down");
        motor1.write(180);
        break;
    }
    irrecv.resume();
  }
}

Kommen denn jetzt die Serial print Ausgaben?
Was für ein Servo hast Du? Viele digital Servos reagieren auf '0' und '180' nicht, weil die Lib da zu kurze bzw. zu lange Impulse erzeugt.
Versuch's mal mit motor1.write(1000) bzw. motor1.write(2000). Darauf muss jedes Servo reagieren.