4 Servos, Bluetooth HM-10, Arduino Uno Help

Hello people,

This is my first project working with Blynk and I’m in need of a little help. I want to create a vehicle that has 2 servos that independently control each side of the vehicle’s steering. I want the other 2 servos to control a conveyor line with buckets attached for digging. One servo will engage the conveyor line and make the buckets rotate. The final one will raise and lower the conveyor line system so that it doesn’t scrape the ground or anything like that.

I’m confident that everything is wired to the breadboard properly. I’m just struggling with coding it so that my phone will communicate with the HM-10, which will communicate with the Arduino, which will in turn control the servos. I think another problem I’m having is that I don’t understand fully what the RX and TX pins do and how/why to code those a certain way.

I have even tried using Blynk’s example code to control one servo and even that won’t work. I selected my board, the connection, and used my authorization token. Here is the example code provided:

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNk_PRINT SwSerial
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
#include <SPI.h>
#include <Servo.h>

char auth[] = "0d1719bc60de4a11872222ec10ed3414";

SoftwareSerial SerialBLE(10, 11); // RX, TX

Servo servo;

BLYNK_WRITE(V3)
{
  servo.write(param.asInt());
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);

  Serial.println("Waiting for connections...");

  servo.attach(9);
}

void loop()
{
  Blynk.run();
}

If someone could please point me in the right direction for controlling just one servo I’m confident that I will be able to figure out the other 3. Thanks in advance for any help!

Also, I can connect to the HM-10 on my phone through the Blynk app, but once I hit the play button in the top right corner to test and see if the button I have associated with V3 works and every time it says “vehicle is offline.” Why is this happening too? As of now I have the code provided uploaded to my board and one servo attached. I am just really struggling getting it to interact via my phone.

The BT module needs to communicate to the Arduino… RX on each device goes to TX on the other device (so Arduino pin 10 connects to BT module TX and Arduino pin 11 to module RX).

The BAUD rates programmed into the BT module must match the BAUD rate specified in the code (9600).

You can Google how to properly connect a BT module to an Arduino… as that is completely independent of Blynk.

I have tried many different things, but for some reason am still unable to use the HM-10 module to get any commands from my phone to go through and control the servos. I have wired the RX and TX as you have said. The BAUD rates are matching. Everything I have researched suggests that it should work.

Is there a problem in my code? I’m not sure what could be the issue as I downloaded the code directly from Blynk.

Also, I am still confused as to why it “goes offline” after I have connected via Bluetooth and then press the play button in the top right.

Change these to pins 2 & 3 (physically as well of course :wink: It is just a WAG, but I seem to recall an issue where attaching a servo will cause PWM issues with certain higher numbered pins… and this may be affecting the SoftwareSerial communication aspect (even though it doesn’t use PWM AFAIK… perhaps some other timing issue).

I GOT IT! Thank you so much… Now one final question (hopefully) if you don’t mind

I’m currently using sliders on Blynk to control the angle that the servo is at. My question is how can I use a button to control the servo going forwards/backwards with continuous rotation? My servos only go 180 degrees as of now, but I am going to go inside them and take off a piece so that it can go 360 degrees.

I messed around with the button widget a little bit and as of now if I press the button the servo will rotate. The problem is that whenever I release the button it goes back to its initial position of 0. I want it to stop rotating after releasing the button, not rotate back to its initial position.

There is a bit more involved then simply removing the stop block… make sure you follow all the guidelines that you find.

If I recall correctly, the speed and direction of a servo in continuous rotation is still based on the same PWM like servo signal. Somewhere near central of the range is stop, and the further away to the lower or higher range is the direction and increasing speed.

So basically you need to use a button and/or slider combo to map out those ranges. So many different ways of control… You can use a slider and have it centered for stop and moving it either direction for servo direction & speed.

Buttons are one or the other setting… so your button, if linked to a physical pin will not have any fine control

Using virtual pins, if() else logic and Arduino map() commands will give you more precision with a finer slider range mapped down to the servo range. and/or button control logic.

I have made one of my servos capable of rotating 360 degrees. Now, it only has three wires instead of the initial three. The signal wire has been removed and all that is left is a ground and hot wire.

I think controlling it via a button will work best for me for this project. The problem is now I am not sure how to wire the servo properly to the Arduino to make it work. I have one of the wires connected to a PWM pin and tried using the same commands as I did before in Blynk:

BLYNK_WRITE(V5)
{
servo1.write(param.asInt());
}

//end code

When I go to associate a button with the V5 pin in the app I get no rotation. Obviously the servo rotates 360 degrees when I just connect it to ground and 5V, but I’m not sure how to code it using if() else logic and the map() command. Any suggestions or guidance?

Well… it is no longer a servo then :hushed: just a DC motor that you cannot control directly from your device. and attempting to will damage whatever pin (if not the whole board) if you try to power that 5v pin with PWM.

Google proper ways to turn a servo into a constant rotation servo.

You are correct, it is now essentially a DC motor except I am still using servo.h in my code.

I still would like to basically send power to it when I hit a button and then it will stop rotating when I am not pushing the button.

How can I code this based on the existing code I have already posted?

You can delete the servo.h as you can no longer use it with that “servo”… you pretty much lobotomised it :stuck_out_tongue:

Now you need a motor controller module and simple digital pin combos to control the H-Bridge…

Do you mean a motor shield? Is there a way to do it with just the my Arduino Uno that I’m using right now?

A shield is just a way of describing a module that form-fits a microcontroller… so yes :wink: Motor shield or standalone motor module.

NO, Running a basic DC motor on a microcontroller requires an H-Bridge based controller. All servos have a miniature one inside… that was the part you lobotomised :stuck_out_tongue:

Ayhow… none of this is actually Blynk relevant, and this is a Blynk forum, not a motor forum :slight_smile: You can Google all this info in much better, clearer detail.