Im doing a project on making a robot dog where i control it using 8 servo motors but for some reason the app wont make servo the move.im using mit app inventor for the app and for the comands i have tested it without anything so im pretty sure that it would work but the problem is that when i press the button on the app nothing works.
This is the code for my project
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <SoftwareSerial.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
#define SERVOMIN 90
#define SERVOMAX 650
uint8_t servonum = 0;
int bluetoothTx = 7;
int bluetoothRx = 8;
SoftwareSerial Bluetooth(bluetoothTx, bluetoothRx);
char Received;
int sit_state = 0;
int shake_state = 0;
int wag_state = 0;
int walk_state = 0;
void setup() {
Serial.begin(9600);
pinMode
Bluetooth.begin(9600);
Serial.println("16 channel Servo test!");
pwm.begin();
pwm.setPWMFreq(60);
}
void loop() {
if (Serial.available() > 0) {
Received = Serial.read();
}
////////// sit //////////
if (sit_state == 0 && Received == '1') {
sit_state = 1;}
if (sit_state == 1){
for (int legle = 45; legle < 135; legle += 10) {
delay(50);
pwm.setPWM(5, 0, angleToPulse(45));
pwm.setPWM(3, 0, angleToPulse(125));
pwm.setPWM(2, 0, angleToPulse(40));
}
delay(1000);
Serial.println("sit");
sit_state = 0;
}
////////// shake //////////
if (shake_state == 0 && Received == '3') {
shake_state = 3;
for (int i = 0; i < 16; i++) {
for (int shak = 45; shak < 450; shak += 10) {
delay(50);
pwm.setPWM(6, 0, shak);
pwm.setPWM(7, 0, shak);
}
}
shake_state = 0;
}
////////// wag //////////
if (wag_state == 0 && Received == '5') {
wag_state = 5;
for (int i = 0; i < 16; i++) {
for (int shak = 45; shak < 450; shak += 10) {
delay(50);
pwm.setPWM(6, 0, shak);
}
for (int shake = 450; shake > 90; shake -= 10) {
delay(50);
pwm.setPWM(7, 0, shake);
}
}
wag_state = 0;
}
////////// walk //////////
if (walk_state == 0 && Received == '7') {
walk_state = 7;
for (int i = 0; i < 16; i++) {
for (int legle = 90, leglee = 530; legle < 530,leglee > 90; legle += 30, leglee -= 30) {
delay(50);
pwm.setPWM(0, 0, legle);
pwm.setPWM(2, 0, legle);
pwm.setPWM(1, 0, leglee);
pwm.setPWM(3, 0, leglee);
// see YouTube video for details (robojax)
}
// robojax PCA9865 16 channel Servo control
delay(300); // wait for 1 second
}
delay(1000);
walk_state = 0;
}
}
int angleToPulse(int ang) {
int pulse = map(ang, 0, 180, SERVOMIN, SERVOMAX);
Serial.print("Angle: ");
Serial.print(ang);
Serial.print(" pulse: ");
Serial.println(pulse);
return pulse;
}
Welcome to the forum. You'll find we're focused on helping you get your project working. To do that, we need some information, as outlined here:
Primarily, your first post gives us no information about how your project is built - how it is wired. A photo might be good, but a schematic would be much better. Without any of that, how are we to know if you've got anything wired at all?
The library you are using says you are using this device...
But you say this...
And your code says this...
You are heading in two directions. Describe the equipment you have and your goal. "A robot dog" is not a valid answer, describe how this project will function.
Im sorry this is my first time making something like this so im unsure about which website i should use to make the schematic.the one i found didnt have a bluetooth or server driver
A photo of a hand drawn circuit is good enough as long as it shows all of the components, the pin numbers being used, all of the interconnections between the components and how they are all powered
Its for a school project the robot is made of plastic pvc board for the outer part and for the inside im gonna use 8 motors,an arduino uno and a server drive to control it (i also have a bread board incase thats needed but so far we havent found a use for it) and my team is using the motors to control the dog like this
Add servos to the mux and add servo ports to the sketch until you get a failure.
Your power supply says "3.7v"... what is the voltage of each servo? Are they all the same? Assuming the voltage is adequate, each servo starts up by going to home/90 degrees and sinks 1.5A... each... and I count nine servos (your text says eight), so the total current just for the servos is 13A. Maybe your power supply is not adequate? Show the specifications of the servo.
Mit app inventor is a website and im sorry if the video is bad because the parts are at school so i cant make another recording and the battery ran out so im trying to buy another one . The robot can move because of the motors, the one in the video is for the legs 4 motors are for the legs 1 motor is for the tail and 2 are for the head (1 for the face and the other is for the neck)
Sorry i did that drawing really late the servo is 8 and my friend did test out the code already and it does work fine but the only problem is that it cant connect to the app and im not sure whats the problem cause i use this vid as a refrence