Controlling a servo remotely

Hello,

I'm making a project that will allow me to control a servo connected to an Arduino mega from a joystick that will be connected to another mega. Eventually the servo will have camera on it for video feed etc. The camera will be at one side of the room with the joystick at another.

So far when the joystick button is presses I can get the servo to do an automatic sweep function and this is on a timer so it will keep doing this. When the button is pressed again it well then receive manual command.

The trouble I'm now having is how do I now get control of the servos using the joystick that at the other end of the room on the sending Arduino? I'm doing this wired and it is likely it will stay that way. The camera has not been integrated yet, just trying to get the basics down first .

Any help would be great as I feel like I'm at a road block currently

consider using an ethernet-shield-rev2 sending UDP datagrams

what camera are you thinking of using?

This could be a possibility, but is there a way without this?

Using the Raspberry Pi AI camera, more data lines to come!

give more details of the project

there may be better alternatives, e.g. ESP32 with the RPI communicating using WiFi

The overall project is essential a remote camera that can be either doing an automatic sweep or controlled manually from another location.

We have 3 sensors that will be with the AL camera at one location and then a screen with the joystick at another.

Sensors will pick up noise or movement and the camera will pan to this location, with the AL function if it picks up a person it will set a buzzer off and then who ever is in the location where the buzzer is can manually then take control of the camera with a joystick

seems that you need to start with machine-to-machine communication, once you have that working you can easily add commands to do more things

So I have them connected and can send a receive commands, I have it so that when I click the joystick and sweep is send the servo will do this, I can then click it again and it will send a manual command and stop the sweep command

where I'm stuck is when I'm now in manual mode how do I control the servo with the joystick when they are connected to different arduinos

send a command with the desired servo position

presuambly you can support different commands

I can send different commands, however what I need to be able to do is move the servo as I please with the joystick not just to set positions

each change in joystick position sends a new command

I'm not sure how I would code this in? do I need to put this in both my send and receive programs?

you need to monitor the joystick position when in this manual mode and whenever there is a change in one of the values (x or y), send a command

... radio control...

.., bluetooth, IR control...

1 Like

would this be easier with a Bluetooth module as currently I'm going in circles and getting nowhere?

The DroneBotWorkShop links have accompanying videos... so grab a full meal, start the videos, follow along in the text. Easier is not possible. Either of these methods involve connecting, configuring and programming the hardware.

1 Like

you would have the same issues with bletooth

if you can already send/receive commands, it seems the problem is determining when to send commands

can you monitor your joystick and recognize when its position has changed?

Take a different approach! Make the structure of your message contain the status and position of every part of your project, rather than individual commands. On the command Arduino, change any one or more of the fields each time you make a physical change, such as a joystick. Send this structured message at a constant time interval.

On the receive/slave end, read each message and if one of the fields has changed from the previous message, make your component follow the new value.

2 Likes

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