Author Topic: problems with the landing legs movement  (Read 923 times)

Offline laizzeman

  • Drinks Maker
  • *
  • Posts: 2
  • Karma: +0/-0
  • rookie
    • View Profile
problems with the landing legs movement
« on: February 26, 2020, 08:35:17 AM »
okey so im using this code that were posted on this site. i also link my electronic schematic so someone can check if thats correct.
my problem is that the servo is only turning into one direction. hope someone can help me to fix this.



// Designed for Skull Quadcopter
// Rev 1.0


#include <Servo.h>
#include <PinChangeInt.h>




// Define RX variables
#define PIN1 2
#define PIN1dataReg PIND
#define pin1state (PIN1dataReg & (1 << PIN1))
volatile long pulseStart1; // pulse start time measured from millies in ISR for pin 1
volatile long pulseTime1; // pulse width time measured from millies in ISR for pin 1 <-- this is the output we require


Servo myservo;  // create servo object to control a servo
int pos = 0;    // variable to store the servo position


// Define Microswitch pins
const int msdown = 5;
const int msup = 4;
int msdownstate = 0;
int msupstate = 0;


// Define Variables for LEDs
int led1 = 6;                    // output pin for LED 1
int led2 = 7;                    // output pin for LED 2
int led3 = 8;                    // output pin for LED 3
int led4 = 9;                    // output pin for LED 4
int led13 = 13;                   // onboard LED indictor incase no others are attached
unsigned long time;              // holds current time for change of state
int flashtime = 400;            // time to flash LEDs in milliseconds
boolean ledon = false;         // remembers start of LED
boolean movedown = true;      // safety feature
boolean moveup = true;        // safety feature


// The below procedure handles the pulse from the RX input
void handlePin1()
{
  if(pin1state)
    pulseStart1=micros(); // we got a positive edge
  else
    pulseTime1=micros()-pulseStart1; // Negative edge: get pulsewidth
}


// LED Control - very basic, can be expanded.
 void turnledoff() {
    digitalWrite(led1, LOW);     
    digitalWrite(led2, LOW);     
    digitalWrite(led3, LOW);     
    digitalWrite(led4, LOW);
    digitalWrite(led13, LOW);   
  }
  void turnledon() {
    digitalWrite(led1, HIGH);     
    digitalWrite(led2, HIGH);     
    digitalWrite(led3, HIGH);     
    digitalWrite(led4, HIGH);     
    digitalWrite(led13, HIGH);
}
  void flashled() {
      // LED Flash
  if (millis() - time > flashtime){
      time = millis();
     
      if (ledon){
        turnledoff();
        ledon = false;
      } else {
        turnledon();
        ledon = true;
      }
     
  }


  }


Offline yang6991906

  • Drinks Maker
  • *
  • Posts: 13
  • Karma: +0/-0
  • rookie
    • View Profile
Re: problems with the landing legs movement
« Reply #1 on: March 01, 2020, 02:46:28 PM »
舵机的信号线是不是应该接到D3上

Offline Bioethical

  • Global Moderator
  • Builder
  • *****
  • Posts: 256
  • Karma: +2/-1
  • "Patience is the mother of science"
    • View Profile
Re: problems with the landing legs movement
« Reply #2 on: May 27, 2020, 03:30:28 AM »
Laizzemann,
I had the same problem and found out that using the stick "Gear" of my RC Spektrum7x moved the motors in both directions.
I hope this helps,
Victor