Jump to content

nnielzz

Members
  • Content Count

    3
  • Joined

  • Last visited

Everything posted by nnielzz

  1. I need to make this for a school project so I can't really stop with this project and start another one :/. The second thing is that I removed irrecv.resume(); on purpose; I wanted it to loop the command but that doesn't really work when I had irrecv.resume(); in the code, so I removed it. To explain what I want to achieve: So I got 2 Servos and 1 IR receiver. The 2 Servos are on pin 13 and 10. The IR receiver is on pin 7. I got a remote control and I want to code it that when I press a button on the remote control, the Servos will start going to a point(degrees) from 0-180 in a loop. Every single button on the remote control will let the Servos go to a point and repeat it. The servos will never stop moving until I press a button which only can stop the Servos from moving, but I should still be able to press the buttons after it stopped. If my plan is to difficult to achieve I'd like to do the following: When I press on a button on the remote control, it doesn't matter which one, the Servo's will start moving repeatedly. Once I click on a button again, the servo's will stop moving. See it as a 'Pause' and 'Play' command. Please help me out
  2. No,I haven't tried that one yet. Could you give me a example of this please ? Also at the moment the servos are moving back and forth, they are going from position 1 to position 2, and since they're 180 degrees servo motors, they can only move from 0 to 180.
  3. Hi, I am quite new with launchpad and Energia and I am trying to code that when I point with my remote control at the IR receiver my two Servo motors will go to a specific point and repeat over and over again, but when I press the same button again they will stop moving. So I got 5 buttons on my small remote control and I want them to each play a different command. I already made something, but the problem with that is that the servo's won't stop moving. Can someone please help me with this? #include <IRremote.h> #include <Servo.h> Servo motorA; //the name of the servo motor Servo motorB; IRrecv irrecv(7); // the receiver connected with pin 7 decode_results results; void setup() { Serial.begin(9600); //serial communication irrecv.enableIRIn(); // start the receiver pinMode(GREEN_LED,OUTPUT); digitalWrite(GREEN_LED,HIGH); digitalWrite(RED_LED,HIGH); motorA.attach(13); // connect the servo with pin 13 and 10 motorB.attach(10); } void loop() { if (irrecv.decode(&results)) { Serial.print("IR code: "); Serial.println(results.value, HEX); int key = results.value % 16; Serial.print("key: "); Serial.println(key); switch (key) { case 2: doKey2(); break; case 3: doKey3(); break; case 4: doKey4(); break; case 7: doKey7(); break; case 8: doKey8(); break; } }} void doKey2(){ //DOWN button on remote control digitalWrite(GREEN_LED,LOW); delay(300); digitalWrite(GREEN_LED,HIGH); motorA.write(0); motorB.write(160); } void doKey3(){ //STROBE button on remote control digitalWrite(GREEN_LED,LOW); delay(300); digitalWrite(GREEN_LED,HIGH); motorA.write(88); motorB.write(126); delay(400); motorA.write(10); motorB.write(120); } void doKey4(){ //SPEED button on remote control digitalWrite(RED_LED,LOW); delay(300); digitalWrite(RED_LED,HIGH); motorA.write(49); motorB.write(160); delay(1000); motorA.write(13); motorB.write(93); } void doKey7(){ //SELECT button on remote control digitalWrite(GREEN_LED,LOW); delay(300); digitalWrite(GREEN_LED,HIGH); motorA.write(90); motorB.write(179); delay(800); motorA.write(138); motorB.write(5); } void doKey8(){ //UP button on remote control digitalWrite(RED_LED,LOW); delay(300); digitalWrite(RED_LED,HIGH); motorA.write(78); motorB.write(120); delay(300); motorA.write(130); motorB.write(12); } void flashLed(int nr) { Serial.print("Flashled: "); }
×
×
  • Create New...