Satellite dish controler with joystick

Hello.
I need help.
I am a beginner and i spend almost 3 days to try programing the arduino and what
i pretend to do is controling a satellite dish off a motorhome with arduino uno.
what i have is 2 dc 12volts motors ,arduino uno, 1 L298N controler , joystick.
Ithink for this project is all i need but if not pease tell me .
what i am trying to do is control the antenna up and down ,right and left with the joystick and all so control the speed.
the project is allready assembly but the critical part is the programing stuff .
If anyone can help me i be very happy.
best regardes
Zfernandes

Welcome to the forum

Please post your best effort at programming this, using code tags when you do

What did google say when you searched for "arduino l298n speed control joystick"?

There's a youtube video called Controlling DC Motors with the L298N H Bridge and Arduino. It's a good half hour watch that will lead you through the specifics.

You can find the description and code for the video on the DroneBot Workshop website.

do you need joystick?

couldn't you use 4 buttons? one pair to drive the dish up/down and another pair left/right. or even just 3 buttons, on to select up/down or left/right

I'm no expert on satellite dishes, but do you need up/down? Quite a few years ago here in the UK, I had a dish that was motorised along the horizontal axis (arc?) so I could point the dish at either the Astra satellite(s) (SKY TV), or one of the others close to it (them) at the time.

Agree. Or, a couple of center-off SPDT toggle switches. Get the kind that spring back to center when released (momentary).

hello i can use the butons too i havit here.

thank you for tip but is a motorhome need to have two axels.

thanks for the tip but allready do that and the principal issue is move the axel in a independent way ,and iam trying to change the program values and codes .

what i have is this .

This is what i am tryng to change but i dont now how ....

/*
L298N Motor Control Demonstration with 2 Potentiometers
L298N-Motor-Control-Demo-2pots.ino
Demonstrates use of 2 potentiometers with Arduino and L298N Motor Controller

DroneBot Workshop 2017
http://dronebotworkshop.com

*/

// Motor A

int enA = 9;
int in1 = 8;
int in2 = 7;

// Motor B

int enB = 3;
int in3 = 5;
int in4 = 4;

// Speed control potentiometers

int SpeedControl1 = A0;
int SpeedControl2 = A1;

// Motor Speed Values - Start at zero

int MotorSpeed1 = 0;
int MotorSpeed2 = 0;

void setup()

{

// Set all the motor control pins to outputs

pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);

}

void loop() {

// Set Motor A forward

digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);

// Set Motor B forward

digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);

// Read the values from the potentiometers

MotorSpeed1 = analogRead(SpeedControl1);
MotorSpeed2 = analogRead(SpeedControl2);

// Convert to range of 0-255

MotorSpeed1 = map(MotorSpeed1, 0, 1023, 0, 255);
MotorSpeed2 = map(MotorSpeed2, 0, 1023, 0, 255);

// Adjust to prevent "buzzing" at very low speed

if (MotorSpeed1 < 8)MotorSpeed1 = 0;

if (MotorSpeed2 < 8)MotorSpeed2 = 0;

// Set the motor speeds

analogWrite(enA, MotorSpeed1);
analogWrite(enB, MotorSpeed2);

}

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

consider (only 2 buttons for motor-1 implemented)
corrected MotorOff

struct Motor {
    const byte  PinEn;
    const byte  PinOut1;
    const byte  PinOut2;
    const char* label;
};

// Arduino UNO PWM pins: 2, 5, 6, 9, 10, 11
#define MyHW
#ifdef MyHW
Motor motor [] = {
    { 10, 12, 3, "Motor-1" },
    { 11, 13, 4, "Motor-2" },
};

const byte PinButs [] = { A1, A2, A3 };
#else
Motor motor [] = {
    { 9, 8, 7 },
    { 3, 4, 5 },
};

const byte PinButs [] = { A1, A2, A3 };
#endif

#define N_MOT   (sizeof(motor)/sizeof(Motor))
#define MotorSpd    100
#define MotorOff     0

#define N_BUT   sizeof(PinButs)
byte butSt [N_BUT];

char s [80];

// -----------------------------------------------------------------------------
enum { MotOff, MotFor, MotRev };
void
motorDr (
    Motor  &m,
    int     dir )
{
    sprintf (s, "%s: %d  %s", __func__, dir, m.label);
    Serial.println (s);

    if (MotOff == dir)  {
        analogWrite  (m.PinEn,   MotorOff);
        digitalWrite (m.PinOut1, LOW);
        digitalWrite (m.PinOut2, HIGH);
        return;
    }

    if (MotFor == dir)  {
        digitalWrite (m.PinOut1, HIGH);
        digitalWrite (m.PinOut2, LOW);
    }
    else   {
        digitalWrite (m.PinOut1, LOW);
        digitalWrite (m.PinOut2, HIGH);
    }

    analogWrite  (m.PinEn,   MotorSpd);
}

// -----------------------------------------------------------------------------
enum { ButP, ButN, ButLR };

void loop ()
{
    for (unsigned n = 0; n < N_BUT; n++)
        butSt [n] = digitalRead (PinButs [n]);

    if (LOW == butSt [ButP])
        motorDr (motor [0], MotFor);
    else if (LOW == butSt [ButN])
        motorDr (motor [0], MotRev);
    else
        motorDr (motor [0], MotOff);
}

// -----------------------------------------------------------------------------
void setup()
{
    Serial.begin (9600);

    for (unsigned n = 0; n < N_BUT; n++)  {
        pinMode (PinButs [n], INPUT_PULLUP);
        butSt [n] = digitalRead (PinButs [n]);
    }


    for (unsigned n = 0; n < N_MOT; n++)  {
        analogWrite  (motor [n].PinEn,   MotorOff);
        digitalWrite (motor [n].PinOut1, LOW);
        digitalWrite (motor [n].PinOut2, LOW);

        pinMode (motor [n].PinEn,   OUTPUT);
        pinMode (motor [n].PinOut1, OUTPUT);
        pinMode (motor [n].PinOut2, OUTPUT);
    }
}

Your system has no positional feed back so you don't know where the dish is pointing, so even if you get it to work like you want it will not be of any use to you.

You need first to rotate your dish to a fixed compass location so that you are pointing at the ecliptic. Then the dish itself needs mounting so that your other axis of control simply scans the ecliptic like described in post #7.

The dish itself must be accurate and repeatable to about half a degree. That is not going to happen without any feed back.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.