For a stroke patient with muscle spasticity, their hands are often clenched closed. Thus, to help with the unclenching of the fist, our device requires a string or cable that pulls and decreases in length to extend the fingers, and relaxes (and increases in length) to allow for flexion.
One idea to allow for this increase and decrease in cable length for the fingers involves a spooling/winding mechanism. To build this, we purchased a 20-kg continuous rotation servo motor to rotate and help spool the cable, as well as an Arduino Mega to control the motor.
Initial Stage
Coding on the Arduino, we implemented the use of a switch that could produce two functionalities of the servo motor, OFF and ON (rotation of the motor), as seen:
In this diagram, we used an SPDT ON-ON switch, to create an on and off functionality. The schematic of the circuit is as shown:
Figure 1: Breadboard and arduino schematic of the electronic set-up.
Figure 2: Schematic diagram of the set-up.
The relevant code for the mechanism:
#include <Servo.h> //servo library Servo servot; int var = 0; const int buttonPin = 3; int buttonState = 0; void setup() { servot.attach(9); pinMode(buttonPin, INPUT); } void loop() { // put your main code here, to run repeatedly: buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { servot.write(80); // runs the motor at low speed in one direction } else { servot.write(90); // stops the motor } }
In essence, when the switch is turned to ‘ON’, pin 3, which is connected to the switch will read as HIGH. Thus, the servo motor will turn on low speed according to the code. However, if it reads LOW (which is the only other reading that it can have), the servo motor will stop turning.
Moving Forward
After achieving this, we will be moving towards using a 3 way switch to provide three functionalities: OFF, CLOCKWISE rotation and ANTI-CLOCKWISE rotation.
#include <Servo.h> Servo servot; int var = 0; const int buttonPin1 = 3; const int buttonPin2 = 2; int buttonState1 = 0; int buttonState2 = 0; void setup() { servot.attach(9); pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT); servot.write(90); } void loop() { buttonState1 = digitalRead(buttonPin1); buttonState2 = digitalRead(buttonPin2); if ((buttonState1 == HIGH)&&(buttonState2 == LOW)) { servot.write(0); } else if ((buttonState2 == HIGH)&&(buttonState1 == LOW)) { servot.write(180); } else { servot.write(90); } }