View: 254|Reply: 0

Press/Click Either Joystick's Button to Rotate P5 Servo to Opposite Side

[Copy link]

1

Threads

1

Posts

12

Credits

Newbie

Rank: 1

Credits
12
Post time 2018-12-28 23:51:46 | Show all posts |Read mode
I need new code or sketches that will add the following functionality:
  • If either of the two joysticks are pressed or clicked and released
  • Then I want to rotate the ultrasonic servo, or whichever servo is plugged into P5, from an initial extreme to the other extreme.
  • If either of the two joysticks are pressed or clicked and released again
  • Then I want to rotate the ultrasonic servo from the second extreme to the original, default extreme.

I can imagine there are multiple ways to accomplish this.

I would think two additional integers’ values would need to change (eg: from 0 to 1) depending on whether either of the two joysticks (U1 or U2) were pressed.
Q1. How could I declare or define these two additional integers in the AdeeptRemoteControl.ino sketch?
I tried reviewing the attached schematic, but I'm still not sure how to define those integers.


Next, a third additional integer could be defined to change from 0 to 1 when either of the first two additional integers' values are 1.


This third integer would be sent to the motor shield somehow to instruct the servo plugged into P5 to sweep to the opposite side.
Q2. How would I transmit that additional output and receive it as an additional input in AdeeptMotor.ino?


Q3. What would need to change in the AdeeptMotor.ino sketch to change the behavior of the servo connected to P5 in the following manner?:
  • If the third additional integer is 0, then the servo is rotated to the one extreme.
  • If the third additional integer is 1, then the servo is rotated to the other extreme.


I asked some of these questions to support@adeept.com.
The following was their message:

"Hello,
The A4 and A5 interfaces are occupied by the joystick, and the ADXL345 accelerometer also uses these two interfaces in the code we provided. Therefore, if you use both the joystick and the accelerometer, this will inevitably lead to conflicts. You can ask this question in our forum. With your contribution, our products will get better and better.
THX!
2018-12-27


Adeept Technical Support Team
Shenzhen Adeept Technology Co., Ltd.
Website: www.adeept.com"

I'm not sure what the accelerometer is used for, because I never plugged it in.
What code could I remove/comment-out to disable the accelerometer?
Would that prevent any of the inevitable conflicts the support team mentioned?

Could you send me new sketches that I can just upload and troubleshoot?
If not, what code would I need to add and remove/comment-out from each Arduino sketch to accomplish this?

If the joystick buttons can't be used, then I'd like to plug in an additional button that can be programmed the same way.
I can mount any button in my 3D printed enclosure for the remote control, so I would just need help with the code for both sketches.


I'm using the attached Arduino sketches that are dated 2018/6/8, but feel free to send me updated sketches.

Sketches.zip

5.51 KB, Downloads: 45

AdeeptRemoteControlShield.pdf

62.82 KB, Downloads: 46

Reply

Use magic Report

You have to log in before you can reply Login | Sign Up

Points Rules