top of page
Search

Prosthetic arm using movement example using potentiometer

A prosthetic arm is a device used to restore the normal functioning of arm or replace a human arm . It helps the person in movement of his/her arm.... A prosthetic arm is usually controlled using EMG signal . but here we have used potentiometer which helps to mimic the signals from emg . the potentiometer varies the voltage . this varied voltage goes as an input to the microcontroller> we have used 5 potentiometer which indicates the 5 fingers of the hand > the code for it is given below


#include <Servo.h>

#include <LiquidCrystal.h>


// Create an instance of the LiquidCrystal library and the Servo library

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Servo servo1, servo2, servo3, servo4, servo5;


// Define the pins for each servo and analog input

const int servoPins[] = {6, 7, 8, 9, 10};

const int analogPins[] = {A0, A1, A2, A3, A4};


void setup() {

// Set the pin modes for each analog input pin

for (int i = 0; i < 5; i++) {

pinMode(analogPins[i], INPUT);

}

// Initialize the LCD and set the cursor to the top row

lcd.begin(16, 2);

lcd.setCursor(0, 0);

lcd.print("Analog Input: ");


// Attach each servo to its pin

servo1.attach(servoPins[0]);

servo2.attach(servoPins[1]);

servo3.attach(servoPins[2]);

servo4.attach(servoPins[3]);

servo5.attach(servoPins[4]);

}


void loop() {

// Read the analog input from each pin and print it to the LCD display

for (int i = 0; i < 5; i++) {

float analogVal = analogRead(analogPins[i]);

float degreeVal = map(analogVal, 0, 1023, 0, 180);

lcd.setCursor(0, i+1);

lcd.print("Pin ");

lcd.print(i);

lcd.print(": ");

lcd.print(analogVal);

lcd.print(" ");


lcd.setCursor(10, i+1);

lcd.print(degreeVal);

lcd.print("deg ");


// Set the servo position based on the analog input

switch(i) {

case 0:

servo1.write(degreeVal);

delay(100);

break;

case 1:

servo2.write(degreeVal);

delay(100);

break;

case 2:

servo3.write(degreeVal);

delay(100);

break;

case 3:

servo4.write(degreeVal);

delay(100);

break;

case 4:

servo5.write(degreeVal);

delay(100);

break;

default:

break;

}

}


// Delay for a short time before repeating the loop

delay(100);

}













simulation link is given below



 
 
 

Comments


Post: Blog2 Post
bottom of page