Please Help with Arduino-Blynk (SERVO)

Overview:
I am a Grade 12 student working on a prosthetic hand using the Arduino. I found out about Blynk through research and wanted to give it a shot. Right now, I am using USB Communication until my HM-10 module arrives.

Specifications and Components Used:

  • 9v External Power Supply
  • Arduino Mega 2560
  • 2 Servo Motors (LKY62)
  • iPhone 7 (iOS 11.4.1)
  • Blynk Library Version: v0.6.1

Problem:
I am trying to use 5-6 Servo Motors (LKY62), but I want to test out two motors before I attempt 5-6.
I tried editing the default servo code in the ‘Blynk Examples’ editor online. Just added more servo motors and added them into different virtual pins.
I can establish the connection with my iPhone to Blynk, and have added a button on Virtual Pin 3. From 0 - 180, on Switch option. Then the same thing with Virtual Pin 4. However, whenever I press the button, nothing happens. When I try the default code, with the same button on Virtual Pin 3, it works.
I am guessing that it’s the problem with the code, because my connections are simple. I have an external 9v power supply attached to the Arduino and have attached the Servo Motors to their designated pins as well as ground/power pins.


// Import LIBRARIES of Blynk and Servo
#include <BlynkSimpleStream.h>
#include <Servo.h>

// AUTHENTICATION TOKEN FROM PROJECT
char auth[] = "2d04f26f1f6f4eb5b01d96f3827c771b";

Servo myservo1;
// myservo1 is PINKY FINGER
Servo myservo2;
// myservo2 is RING FINGER
Servo myservo3;
// myservo3 is MIDDLE FINGER
Servo myservo4;
// myservo4 is INDEX FINGER
Servo myservo5;
// myservo5 is THUMB

//BLYNK Virtual Pins' Functions: 
BLYNK_WRITE(V3){
  myservo4.write(param.asInt()); // Control INDEX FINGER with Motor Rotation
}

BLYNK_WRITE(V4){
  myservo3.write(param.asInt()); // Control MIDDLE FINGER with Motor Rotation
}

BLYNK_WRITE(V5){
  myservo2.write(param.asInt()); // Control RING FINGER with Motor Rotation
}

BLYNK_WRITE(V6){
  myservo1.write(param.asInt()); // Control PINKY FINGER with Motor Rotation
}

BLYNK_WRITE(V7){
  myservo5.write(param.asInt()); // Control THUMB with Motor Rotation
}

// VOID SETUP (Blynk and Servo Motor - Digital Pins): 
void setup()
{
  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  myservo1.attach(9);
  // myservo1 is on digital pin 9
  myservo2.attach(10);
  // myservo2 is on digital pin 10
  myservo3.attach(11);
  // myservo3 is on digital pin 11
  myservo4.attach(12);
  // myservo4 is on digital pin 12
  myservo5.attach(13);
  // myservo5 is on digital pin 13
}

// VOID LOOP: Blynk will run infinite amount of times until disconnected
void loop()
{
  Blynk.run();
}


Have you tested your servos and the digital pins you chose with some basic Servo code (looping rotations, etc.) before trying with Blynk? This is a necessary test to confirm the Servo library, choice of pins, wiring and power all work.

You will be better off sticking with the USB link or using an ESP-01 as a WiFi shield, instead of Bluetooth.

1 Like