top of page

(Apr. 9-15) Robot Ting

This week in shop, I focused on the manual control system for the rc-car. To do this I just removed the pre-installed remote controller and plugged a metro mini up to the steering servo and the electronic speed controller. The metro mini uses i2c to control a pwm controller which controls the esc which controls the motor. The steering servo can be controlled directly from the pwm controller. my next step is to make this exact system but in python on the jetson. After that it would have to be wireless and powered entirely by the on board battery.


#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver myServo = Adafruit_PWMServoDriver();

#define MOTORMIN 300
#define MOTORMAX 350
#define SERVOMIN 160
#define SERVOMAX 410

int joyY = 1;
int joyX = 0;
uint8_t MOTORnum = 15;
uint8_t SERVOnum = 14;

void setup() {
  Serial.begin(9600);
  myServo.begin();
  myServo.setPWMFreq(50);
  Serial.print("Starting Motor");
  myServo.setPWM(MOTORnum, 0, MOTORMIN);
  delay(3000);
}

void loop() {
  double valY = analogRead(joyY); /*value up to 1023 with 518 as neutral. For the Y axis; controls speed */
  double valX = analogRead(joyX); /*value up to 1023 with 518 as neutral. For the X axis; controls pitch */
  double speed = MOTORMIN+((MOTORMAX-MOTORMIN)*((valY-518)/518));
  double yaw = (SERVOMAX-(SERVOMIN/2))+(((SERVOMAX-SERVOMIN)/2)*((valX-518)/518));
  Serial.println(speed);
  myServo.setPWM(SERVOnum, 0, yaw);
  myServo.setPWM(MOTORnum, 0, speed);
}





1 view

Recent Posts

See All
bottom of page