Input Devices

PCB Board

For this week's assignment I used the board that I made for the output devices, as the requirements of the myosensor I used were met by that board. Below you can see which analog pins my board has on it. The pin used for the myosensor was the equivalent of A4 or as noted in the picture below PC4. For the more detailed design and production of the board you can go to the Output Devices. As the bootloader was already burnt on this board, I did not have to do that process again. So, all I had to do was connect my sensor and code it.

Myoware Sensor

A Myoware Muscle Sensor was used for the input devices week. In order to understand how the sensor works, I had to read the datasheet of it. This sensor measures muscle activation via electric potential, referred to as electromyography (EMG). Using electromyography, I could also move servo motors that would control the fingers of my prosthetic arm.

The myoware sensor has three elecrodes that should be connected to the muscle group chosen. Two of the electrodes should be connected in the middle of the muscle whilst the third one should be connected in the end of the muscle. The electrode connected to the end of the muscle is the reference electrode. Before putting the sensor to the muscle, I had to clean the area with Isopropyl Alcohol. If the sensor is not placed correctly, then the readings will be distorted or non-existent. So, the correct placement of the sensor on the muscle is very important.

After the understanding of how the sensor is working, it was time to wire it up and code it. The wiring up of the sensor was taken from the example below.

Software

So, in the beginning I just tried the myosensor printing out some values for it.


void setup() {
  Serial.begin(9600);
}

void loop() {
  //read the input on analog pin 4;
  int sensorValue = analogRead(A4);

  //convert the analog reading (which goes from 0-1023) to a voltage (0-5V);
  float voltage = sensorValue * (5.0 / 1023.0);

  //print out the value you read; 
  //Serial.println(sensorValue);
  Serial.println(voltage);
}

                             

Below, you can see the result of the code above:

Next, I took it a bit further and added a servo motor to it which moves according to the readings of the sensor. This was a first test of the senor controlling a servo motor, which I am planning to use in order to move the fingers of my prosthetic arm. I control the servo motor according to the myosensor values. Below, you can find the code:

 
#include <VarSpeedServo.h>

VarSpeedServo servo;

void setup() {
  // put your setup code here, to run once:
  servo.attach(9);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  
  //read the input on analog pin 4;
  int sensorValue = analogRead(A4);

  //convert the analog reading (which goes from 0-1023) to a voltage (0-5V);
  float voltage = sensorValue * (5.0 / 1023.0);

  //print out the value you read; 
  //Serial.println(sensorValue);
  Serial.println(voltage);

  if (voltage > 3.0){
    servo.write(180, 30, true);
    }
  else
    servo.write(0, 30, false);
}

                            

Below, you can see the result of the above written code:

Downloads

MyowareSensor.ino | MyowareServo.ino