Add pan and tilt service to the robot object.
Add pan and tilt service to the robot object and test it
Tinker Cad Circuit Design:
Components Required:
1) Arduino Uno R3
2) Micro Servo (x2)
3) Potentiometer (x2) 250 kilo Ohms
3) Breadboard Small
Code for the Circuit:
#include <Servo.h>
int sensorValue = 0;
int outputValue = 0;
int sensorValue1 = 0;
int outputValue1 = 0;
Servo servo_9;
Servo servo_7;
void setup(){
pinMode(A0, INPUT);
servo_9.attach(9);
pinMode(A1, INPUT);
servo_7.attach(7);
}
void loop(){
sensorValue = analogRead(A0);
outputValue = map(sensorValue, 0, 1023, 0, 180);
sensorValue1 = analogRead(A1);
outputValue1 = map(sensorValue1, 0, 1023, 0, 180);
servo_9.write(outputValue);
servo_7.write(outputValue1);
delay(10);
}
Comments
Post a Comment