Remote control snow blower

My project is a remote control snow blower
Using all 10 channel FLYSKY FS-I6X
Arduino mega 2560

Using an RC controller to run 12V DC motors to pull cables and use automotive headlight position sensors so the motors basically just rock back and forth about 45 degree or less. Putting tension or releasing tension on the cables.

This is the first of the 10 channels programed for moving the chute up and down.

This is a working sketch to run the blower chute to tilt up and down. The motor is connected to high Amp H Bridge mosfet pwm motor driver. The motor has a 6" long armature with 2 cables attached at the upper and lower ends that move the chute. The headlight position sensor is spring loaded potentiometer ( GM part number #20984248) also attached to the armature.
When I push the joystick forward the armature rocks back ( up to its threshold_Max) pulling the upper cable and releasing tension on the lower cable. When the joystick is pulled back the armature rocks forward releasing tension on the upper cable and pulling tension on the lower cable (up to its threshold_Min). Thus moving the chute up and down.

By using channel 2 with a spring loaded joystick that goes back to center, quick taps will make incremental moves of the arm until it reaches its limits.

Cut and paste the code or upload the ino file.

const int in1 = 45;   //green goes from digital pin 45 and to in1 on the driver

const int in2 = 40;   //grey goes from digital pin 45 to in2 on the driver

const int analogPin = A0;             // orange goes from analog pin A0 to sensor output pin
const int threshold_Min = 200;        // the limits do not allow the motor full rotation
const int threshold_Max = 800;


                        //the following are all ~PWM capable ports 

const int enable1 = 44;  // yellow   goes from PWM pin 44 to enable pin on the driver

const int rc_channe2 = 46;  // blue goes from PWM pin 46 to the RC reciever channel 2





void setup() {

     pinMode(analogPin, INPUT);
  
    pinMode(rc_channe2, INPUT);

    pinMode(in1, OUTPUT);

   pinMode(in2, OUTPUT);

   pinMode(enable1, OUTPUT);

   Serial.begin(9600);


}



void loop() {


  int analogValue = analogRead(analogPin);    //orange sensor reading
  
   Serial.println(analogValue);
  
  
  int pwm = 0;


  int rc2 = pulseIn(rc_channe2, HIGH, 25000);

   
  Serial.print(" raw channe2: ");
    Serial.print(rc2);
 
  
  if(rc2==0){

      Serial.println(" no signal");
     
      digitalWrite(in1, LOW);

      digitalWrite(in2, LOW);

      analogWrite(enable1, 0);

  }else{


   if(rc2 < 1400 && analogValue > threshold_Min ){  // down stick

      pwm = map(rc2, 1400, 1000, 0, 100);   //map speed 0-100   55% speed

      digitalWrite(in1, HIGH);

      digitalWrite(in2, LOW);

      analogWrite(enable1, pwm);

      Serial.print(" down stick: ");
             Serial.println(pwm);
   
   }else{
  
  if(analogValue < threshold_Min){
  digitalWrite (in1, LOW);
  digitalWrite (in2, LOW);           
  analogWrite(enable1, 0);
      
  }

   if(rc2 > 1560 && analogValue < threshold_Max){          //up stick

      pwm = map(rc2, 1560, 2000, 0, 100);  //map speed 0-100   55% speed

      digitalWrite(in1, LOW);

      digitalWrite(in2, HIGH);

      analogWrite(enable1, pwm);

      Serial.print(" up stick: ");
      Serial.println(pwm);
     
  }else{
  if (analogValue > threshold_Max){
  digitalWrite (in1, LOW);
  digitalWrite (in2, LOW);
  analogWrite(enable1, 0);

  }
 
 Serial.println(analogValue);
delay(1);
}
}
}
}

CHUTE_UP_DOWN_D.ino (2.9 KB)

Hi, you are declaring the analogs as constants when we now their values must change to control the directions of the car. Const int´s should only be for non-constant values like a specific time, or an Arduino pin.

that´s the first mistake. You should see some videos about analog pins because you did it al the way wrong. The Arduino never reads what the analog is perceiving.

analogs should be read something like this: ///////////////////////////// int x; int y;

void setup(){ Serial.begin (9600); }

void loop() { x = analogRead(A0); y = analogRead(A1);

Serial.println(x); Serial.println(y); }

As a bit of advice for beginners as me: just don´t use const int till you get some experience to make things clearer.

postdata: sorry for my poor English.

One doesn't have to declare which analogs we are using in the setup or out of the loop, we just need to call the function as you see above.

"However I need to be able to adjust the chute position anywhere in-between the upper and lower limits without having to hold the stick steady."

You might remove the spring in the joystick so it stays where it is when released. Probably a better solution is to use a pot with a large knob (like a 3" plastic jar lid) hot glued on so you just adjust the knob to position the chute where you want it to stay. chasing a spring loaded joystick has control/position issues.

"Never mind buddy, I just figured it out. In a word of advise to you. Don't be giving advise on something you know nothing about."

Now grunt big for daddy and you will probably feel a lot better.

Hi,
Welcome to the forum.

This would have helped you get a better response.

Please read the post at the start of any forum , entitled “How to use this Forum”.
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

This is how your code would be shown, many of the forum members use platforms other than PC, such as smart phones, and these have problems with attachments and dislplaying them.

const int in1 = 45;   //green

const int in2 = 40;   //grey

const int analogPin = A0;
const int threshold_Min = 200;
const int threshold_Max = 800;

//the following are all ~PWM capable ports

const int enable1 = 44;  // yellow

const int rc_channe3 = 46;  // blue

void setup() {
  pinMode(analogPin, INPUT);
  pinMode(rc_channe3, INPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(enable1, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int analogValue = analogRead(analogPin);
  Serial.println(analogValue);
  int pwm = 0;
  int rc3 = pulseIn(rc_channe3, HIGH, 25000);
  Serial.print(" raw channe3: ");
  Serial.print(rc3);
  if (rc3 == 0) {
    Serial.println(" no signal");
    digitalWrite(in1, LOW);
    digitalWrite(in2, LOW);
    analogWrite(enable1, 0);
  } else {
    if (rc3 < 1460 && analogValue > threshold_Min ) {
      pwm = map(rc3, 1460, 1000, 0, 100);   //map our speed to 0-100 range 55% speed
      digitalWrite(in1, HIGH);
      digitalWrite(in2, LOW);
      analogWrite(enable1, pwm);
      Serial.print(" left stick speed: ");
      Serial.println(pwm);
    } else {
      if (analogValue < threshold_Min) {
        digitalWrite (in1, LOW);
        digitalWrite (in2, LOW);
        analogWrite(enable1, 0);
      }
      if (rc3 > 1530 && analogValue < threshold_Max) {        //right stick
        pwm = map(rc3, 1530, 2000, 0, 100);  //map our speed to 0-100 range 55% speed
        digitalWrite(in1, LOW);
        digitalWrite(in2, HIGH);
        analogWrite(enable1, pwm);
        Serial.print(" right stick speed: ");
        Serial.println(pwm);
      } else {
        if (analogValue > threshold_Max) {
          digitalWrite (in1, LOW);
          digitalWrite (in2, LOW);
          analogWrite(enable1, 0);
        }
        Serial.println(analogValue);
        delay(1);
      }
    }
  }
}

Tom… :slight_smile:

The problem is typically solved by an incremental value. The joystick can signal two directions, which can be used to increment and decrement the set value. A pause should be added after each increment, so that the increment is repeated only after some time, or stops until the joystick is released. And of course checks have to be added that the set value always remains within its bounds.

Hi, Can you please post your final working code please/

Tom.. :)

“Thus moving the chute up and down. However I need to be able to adjust the chute position anywhere in-between the upper and lower limits without having to hold the stick steady.”

In a joy stick setup like that (assuming an analog input from a joystick pot) I would just set the code for an increasing/decreasing rate of change (ie. stepper speed) the greater/lesser the distance from the pot neutral point. Higher and lower than the neutral point would determine the direction of the stepper motor. That way the final the joystick position is always in its neutral resting position when the chute is positioned as desired. Should be fairly simple.