Shoe insole pressure sensing map

Hey everyone!
I have made a shoe-insole with a pressure sensor array in form of rows and columns and a velostat between both layers. So know my idea is to make a visualized presentation of the insole and to show on the display where the pressure on it is applied and ideally how big so it changes the colors when pressure is big it is red, green for low pressure etc… I am completely new to processing and have never worked with it before so maybe someone of you guys could give me advise.
I have an array of 6x12 (6 columns and 12 rows of copper tape). Therefore I am using for my circuit two 16-channel-analog mulitplexer from sparkfun and an arduino pro mini.

I appreciate any kind of help! Thank you…

Do you read values in Processing? Great, go to step 2.

Can you placed your data in an array or a similar structure? Great, go to step 3.

Mapping of pressure ranges to color ranges. Use HSB mode for this task. This requires for you to know what is the min and max values you expect to get from your sensors (via sparkfun/arduino). Do we know this? G8 => goto step 4

Map your data structure to a color map structure. Finally…

Display the color map structure.

What step are you at?

Kf

lol i think I am still at step 1 :joy: I don’t know much of programming.
I just want something similiar like this here https://www.youtube.com/watch?v=wvJvYTQQDM0. Thats it.

This is totally doable in Processing. Unfortunately the first part falls under your shoulders as it is very unlikely anybody will have the technology (hardware setup) to run it. No despair, I bet there are some resources online in Arduino.cc site or similar sites. When you find some Ardunio and Processing code that works for you, then we can go to step 2. Are you confident to get the first part running?

Kf

Appreciate your help so much! I already have found something similar and a code for Arduino and Processing and I tried to adapt it on my project but that doesn’t work at all. Do you have a private email or skype, where I can contact you so I can explain the technology I have already built up and the sketches I have found?? Thanks again.

I would prefer you share your basic design concepts as this will help other ppl, or more importantly, other ppl could provide you with valuable feedback. I provide feedback whenever I can.

Kf

So like i said before, i have made a form of a shoe-insole on which i have place on the one side 6 columns of copper tape and on the other side 12 rows of copper tape. In between I have place the velostat. Thats the breadboard schematic for the arduino and the multiplexer https://cdn.instructables.com/FDC/6B90/IB3HOF9S/FDC6B90IB3HOF9S.LARGE.jpg. (Here you can see a array of 15x15, I use a 6x12 array like i already mentioned.)
Thank you!

Do you have your ino code working? Are you ready to start transfering data to Processing?

Kf

yes, thats the code for the 15x15 array. but for my 12x6 it doesn’t work when i change the values. if i try it with the 15x15 array, then it works. Why? What’s wrong?

//Mux control pins for analog signal (SIG_pin) default for arduino mini pro
const byte s0 = 13;
const byte s1 = 12;
const byte s2 = 11;
const byte s3 = 10;

//Mux control pins for Output signal (OUT_pin) default for arduino mini pro
const byte w0 = 9; 
const byte w1 = 8;
const byte w2 = 7;
const byte w3 = 6;

//Mux in "SIG" pin default for arduino mini pro 
const byte SIG_pin = 0; 

//Mux out "SIG" pin default for arduino mini pro
const byte OUT_pin = 5;

//Row and Column pins default for arduino mini pro
const byte STATUS_pin = 3;
const byte COL_pin = 2;

const boolean muxChannel[16][4]={
    {0,0,0,0}, //channel 0
    {1,0,0,0}, //channel 1
    {0,1,0,0}, //channel 2
    {1,1,0,0}, //channel 3
    {0,0,1,0}, //channel 4
    {1,0,1,0}, //channel 5
    {0,1,1,0}, //channel 6
    {1,1,1,0}, //channel 7
    {0,0,0,1}, //channel 8
    {1,0,0,1}, //channel 9
    {0,1,0,1}, //channel 10
    {1,1,0,1}, //channel 11
    {0,0,1,1}, //channel 12
    {1,0,1,1}, //channel 13
    {0,1,1,1}, //channel 14
    {1,1,1,1}  //channel 15
  };


//incoming serial byte
int inByte = 0;

int valor = 0;               //variable for sending bytes to processing
int calibra[15][15];         
int minsensor=254;          //Variable for staring the min array
int multiplier = 254;
int pastmatrix[15][15];

void setup(){
    
  pinMode(s0, OUTPUT); 
  pinMode(s1, OUTPUT); 
  pinMode(s2, OUTPUT); 
  pinMode(s3, OUTPUT); 
  
  pinMode(w0, OUTPUT); 
  pinMode(w1, OUTPUT); 
  pinMode(w2, OUTPUT); 
  pinMode(w3, OUTPUT); 
  
  pinMode(OUT_pin, OUTPUT); 
  
  pinMode(STATUS_pin, OUTPUT);
  pinMode(COL_pin, OUTPUT);

  
  digitalWrite(s0, LOW);
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
  
  digitalWrite(w0, LOW);
  digitalWrite(w1, LOW);
  digitalWrite(w2, LOW);
  digitalWrite(w3, LOW);
  
  digitalWrite(OUT_pin, HIGH);
  digitalWrite(STATUS_pin, HIGH);
  digitalWrite(COL_pin, HIGH);
  
 
  
  Serial.begin(115200);
  
  Serial.println("\n\Calibrating...\n");
  
  // Full of 0's of initial matrix
  for(byte j = 0; j < 15; j ++){ 
    writeMux(j);
    for(byte i = 0; i < 15; i ++)
      calibra[j][i] = 0;
  }
  
  // Calibration
  for(byte k = 0; k < 50; k++){  
    for(byte j = 0; j < 15; j ++){ 
      writeMux(j);
      for(byte i = 0; i < 15; i ++)
        calibra[j][i] = calibra[j][i] + readMux(i);
    }
  }
  
  //Print averages
  for(byte j = 0; j < 15; j ++){ 
    writeMux(j);
    for(byte i = 0; i < 15; i ++){
      calibra[j][i] = calibra[j][i]/50;
      if(calibra[j][i] < minsensor)
        minsensor = calibra[j][i];
      Serial.print(calibra[j][i]);
      Serial.print("\t");
    }
  Serial.println(); 
  }
  
  Serial.println();
  Serial.print("Minimum Value: ");
  Serial.println(minsensor);
  Serial.println();
  
  establishContact();
 
  digitalWrite(COL_pin, LOW);
}


void loop(){
  //Loop through and read all 16 values
  //Reports back Value at channel 6 is: 346
  if (Serial.available() > 0){
    inByte = Serial.read();
    
    if(inByte == 'A'){
    
      for(int j = 14; j >= 0; j--){ 
        writeMux(j);
        
        for(int i = 0; i < 15; i++){
            
          valor = readMux(i);
          
          //Saturation sensors
          int limsup = 450;
          if(valor > limsup)
            valor = limsup;
            
          if(valor < calibra[j][i])
            valor = calibra[j][i];  
          
          valor = map(valor,minsensor, limsup,1,254); 
          
          if(valor < 150)
            valor = 0;
          if(valor > 254)
            valor = 254;
          
          Serial.write(valor);
          digitalWrite(COL_pin,!digitalRead(COL_pin));
        } 
      }
    }
        
  }
}


int readMux(byte channel){
  byte controlPin[] = {s0, s1, s2, s3};

  //loop through the 4 sig
  for(int i = 0; i < 4; i ++){
    digitalWrite(controlPin[i], muxChannel[channel][i]);
  }

  //read the value at the SIG pin
  int val = analogRead(SIG_pin);

  //return the value
  return val;
}

void writeMux(byte channel){
  byte controlPin[] = {w0, w1, w2, w3};

  //loop through the 4 sig
  for(byte i = 0; i < 4; i ++){
    digitalWrite(controlPin[i], muxChannel[channel][i]);
  }
}

void establishContact() {
  while (Serial.available() <= 0) {
    Serial.print('A');   // send a capital A
    delay(300);
  }
}

so no one can help me? :thinking:

Hi.

I bet this guy can help you with every step :stuck_out_tongue:
I guess I could too but I’m busy, sorry.

You see, in your code you have 15 all over the place. I can only guess that when you went from 15x15 to 12x6, you forgot to update all the code properly. Did you notice you have 14 in your code? Those values are used when you are interacting over your array backwards. Proper way is to use

const int NROWS=15;
const int NCOLS=15;

for (byte i = 0; i < NCOLS; i ++) { ... }

//  OR

for (int j = NCOLS-1; j >= 0; j--) {  ...}

Kf