Use your muscles to control anything! MyoWare Muscle Sensor | Arduino


Today we will learn how to use the Myo Ware muscle sensor and control a servo motor. So with this sensor you can control a robotic hand, or you can use your muscles to control anything. This sensor all in one electromyography (EMG) sensor from Advancer Technologies. The MyoWare board measures the filtered electrical activity of a muscle and provides voltage output depending on the amount of activity in the selected muscle. Required Hardware: MyoWare Muscle Sensor - https://amzn.to/2ucFcu6 Electrode Pad - https://amzn.to/2u24Fr3 Mg90s Servo Motor - https://goo.gl/qTsxsZ Arduino Nano V3 - https://goo.gl/QbEmNL Breadboard - https://goo.gl/uvEhR1 Jumper Wire - https://goo.gl/EGTafY Adjustable Solder Kit - https://goo.gl/2oZhtu Solder Wire - https://goo.gl/FC7W6o Best Sellers: 4DOF Robot Arm - https://goo.gl/SjS5E8 Anet A8 3D Printer - https://goo.gl/rpdqQ4 Voice Recognition Module - https://goo.gl/SLAS4T ------------------------------------------------------------------------ Studio Lighting Softbox - https://goo.gl/PM3xTM Adjustable SoftBox Tripod - https://goo.gl/j1N2UP Zhiyun Smooth Q Gimbal - https://goo.gl/wcNqB8 Magnetic Blue Mat - https://goo.gl/5j4Q7y Subscribe to Channel - http://bit.ly/MertArduino https://www.facebook.com/mertarduino/


Source Code:
#include <Servo.h>

//Threshold for servo motor control with muscle sensor. 
//You can set a threshold according to the maximum and minimum values of the muscle sensor.
#define THRESHOLD 200

//Pin number where the sensor is connected. (Analog 0)
#define EMG_PIN 0

//Pin number where the servo motor is connected. (Digital PWM 3)
#define SERVO_PIN 3

//Define Servo motor
Servo SERVO_1;

/*-------------------------------- void setup ------------------------------------------------*/

void setup(){
  
  //BAUDRATE set to 9600, remember it to set monitor serial properly. 
  Serial.begin(9600);
  
  //Set servo motor to digital pin 3
  SERVO_1.attach(SERVO_PIN);
}

/*--------------------------------  void loop  ------------------------------------------------*/

void loop(){

  //The "Value" variable reads the value from the analog pin to which the sensor is connected.
  int value = analogRead(EMG_PIN);

  //If the sensor value is GREATER than the THRESHOLD, the servo motor will turn to 180 degrees.
  if(value > THRESHOLD){
    SERVO_1.write(179);
  }

  //If the sensor is LESS than the THRESHOLD, the servo motor will turn to 0 degrees.
  else{
    SERVO_1.write(0);
  }

  //You can use serial monitor to set THRESHOLD properly, comparing the values shown when you open and close your hand.
  Serial.println(value);
}