Servo Shield and RC Transmitter via Arduino Uno
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- headbyte
- Posts: 12
- Joined: Wed Oct 20, 2021 12:22 pm
Re: Servo Shield and RC Transmitter via Arduino Uno
I have some "hardware" chops. I've been an electronic & computer tech for over 20 yrs. But my coding sucks. :/
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: Servo Shield and RC Transmitter via Arduino Uno
Nice looking tank!
And you can declare some handy constants for use in the code:
You can eliminate your include of the Servo.h and your declarations of the Servo objects and the servo attach statements, since they are no longer needed.
In your setup, you will need to add the following lines to initialize the shield.
And this code:
can be replaced by:
First, you need to include the library and declare your shield. Since you altered the default address, you will need to specify that in the constructor.So how do I get this code . . . To work with the Servo Shield?
Code: Select all
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver servos = Adafruit_PWMServoDriver(0x41);
Code: Select all
#define SERVOMIN 150 // This is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 600 // This is the 'maximum' pulse length count (out of 4096)
You can eliminate your include of the Servo.h and your declarations of the Servo objects and the servo attach statements, since they are no longer needed.
In your setup, you will need to add the following lines to initialize the shield.
Code: Select all
servos.begin();
servos.setOscillatorFrequency(27000000);
servos.setPWMFreq(50); // Analog servos run at ~50 Hz updates
Code: Select all
servo1.write(map(ch4, -100, 100, 0, 180));
servo2.write(map(ch3, -100, 100, 0, 180));
Code: Select all
servos.setPWM(0, 0, map(ch4, -100, 100, SERVOMIN , SERVOMAX)); // for servo connected to shield channel 0
servos.setPWM(1, 0, map(ch3, -100, 100, SERVOMIN , SERVOMAX)); // for servo connected to shield channel 1
- headbyte
- Posts: 12
- Joined: Wed Oct 20, 2021 12:22 pm
Re: Servo Shield and RC Transmitter via Arduino Uno
Thank you so much for your reply! This is great! I truly appreciate it.
Please be positive and constructive with your questions and comments.