├── README.md ├── data_reader.ino └── emg_control.ino /README.md: -------------------------------------------------------------------------------- 1 | # Arduino-EMG-sensor 2 | To get started connect the EMG sensor to a muscle of your choice. Then open up the serial monitor and look for the maximum and minimum value. The value 'x' has to be between the maximum and minimum. You have to try and see which value works best for you. 3 | -------------------------------------------------------------------------------- /data_reader.ino: -------------------------------------------------------------------------------- 1 | //Serial printer for the EMG sensor 2 | //This code is for printing the EMG value on the 3 | //serial monitor. 4 | // 5 | //© Au Robots 8.4.2017 6 | 7 | 8 | void setup() { 9 | Serial.begin(9600); 10 | } 11 | 12 | void loop() { 13 | Serial.println(analogRead(x)); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /emg_control.ino: -------------------------------------------------------------------------------- 1 | //EMG sensor robotic hand controller 2 | //This code is for controlling a robotic hand with 3 | //an EMG sensor. 4 | // 5 | //© Au Robots 8.4.2017 6 | 7 | 8 | //Necessary for controlling the servos 9 | #include 10 | 11 | const int x = ///// This is the reference value and it 12 | //will depend on your setup. You have to find it out 13 | //yourself by looking at the serial monitor and finding 14 | //a value between the maximum and minimum value. 15 | 16 | //Naming the servos 17 | Servo servo1; 18 | Servo servo2; 19 | Servo servo3; 20 | Servo servo4; 21 | Servo servo5; 22 | Servo servo6; 23 | 24 | void setup() 25 | { 26 | //Starting the serial monitor 27 | Serial.begin(9600); 28 | 29 | //Configuring servo pins 30 | servo2.attach(10); // pinky 31 | servo3.attach(11); //ring 32 | servo4.attach(3); // middle 33 | servo5.attach(6); //index 34 | servo6.attach(5); //thumb 35 | } 36 | 37 | 38 | void loop() 39 | { 40 | //Printing the EMG data 41 | Serial.println(analogRead(5)); 42 | 43 | //If the EMG data is greater than x the hand closes 44 | if(analogRead(5) > x) { 45 | servo2.write(180); 46 | servo3.write(148); 47 | servo4.write(89); 48 | servo5.write(180); 49 | servo6.write(180); 50 | } 51 | 52 | //If the EMG data is lower than x the hand opens 53 | else if (analogRead(5) < x) { 54 | servo2.write(38); 55 | servo3.write(10); 56 | servo4.write(0); 57 | servo5.write(16); 58 | servo6.write(16); 59 | } 60 | 61 | //A delay to slow down the process 62 | delay(100); 63 | } 64 | 65 | --------------------------------------------------------------------------------