Arduino version of Stanford Parkinson’s gloves developed by Peter Tass

Posted by in Nuevas Tecnologías

This code is an Arduino program that randomly flashes motors connected to digital pins 2 to 9.

The Arduino digital outputs are used to drive button-type vibrator motors that are cheap and easy to buy.

The idea is to follow the procedure described in this article:

First, constants are defined for each of the digital pins to which the motors are connected.

There is a function called «estaenvector» that takes a value and a vector as arguments and returns true if the value is found in the vector and false otherwise.0

This function is used later to ensure that the random values assigned to the motors are unique.

There is also a function called «aleatorio» that takes a pointer to a vector and the size of the vector as arguments.

This function assigns random values to each element of the vector, ensuring that the values are unique.

In the «setup» block, all pins are configured as outputs and all motors are turned off at the start.

In the «loop» block, the «aleatorio» function is called to generate a vector of four random values, then the vector is traversed and the motors corresponding to each value of the vector are turned on.

Then, a delay of 100 milliseconds is waited before moving on to the next element of the vector.

Finally, a delay of 133 milliseconds is waited twice before starting the loop again.

const int izq1 = 2;
const int izq2 = 3;
const int izq3=4;
const int izq4=5;
const int der1=6;
const int der2=7;
const int der3=8;
const int der4=9;

bool estaenvector(int valor,int array[],int tam)
  int cont;
  for (cont=0;cont<tam;cont++){
    if (array[cont]==valor) {break;}
  if (cont<tam) {
  else {

void aleatorio (int *v,int n)
  int aux;
  int contador=0;
    if (!(estaenvector(aux,v,n))) { 
  } while (contador<n);

void setup()
  pinMode(izq1, OUTPUT);
  pinMode(izq2, OUTPUT);
  pinMode(izq3, OUTPUT);
  pinMode(izq4, OUTPUT);
  pinMode(der1, OUTPUT);
  pinMode(der2, OUTPUT);
  pinMode(der3, OUTPUT);
  pinMode(der4, OUTPUT);

void loop()
  int n;
  int vector[4]={0,0,0,0};
  for (n=0;n<4;n++){
    digitalWrite(izq1, LOW);
    digitalWrite(der1, LOW);
    digitalWrite(izq2, LOW);
    digitalWrite(der2, LOW);
    digitalWrite(izq3, LOW);
    digitalWrite(der3, LOW);
    digitalWrite(izq4, LOW);
    digitalWrite(der4, LOW);
    if (vector[n]==1) {
    	digitalWrite(izq1, HIGH);
      	digitalWrite(der1, HIGH);
    if (vector[n]==2) {
    	digitalWrite(izq2, HIGH);
      	digitalWrite(der2, HIGH);
    if (vector[n]==3) {
    	digitalWrite(izq3, HIGH);
      	digitalWrite(der3, HIGH);
    if (vector[n]==4) {
    	digitalWrite(izq4, HIGH);
      	digitalWrite(der4, HIGH);
  for (n=0;n<2;n++){

Here de Code:

This is a first approach to the problem and contributions to the project code are appreciated.