Katta Rishabh
Published

Smart Shoes

Walking towards a better future.

IntermediateShowcase (no instructions)8,002
Smart Shoes

Things used in this project

Hardware components

Piezo Sensor
ControlEverything.com Piezo Sensor
×1
Ultrasonic Sensor
×1
AA Batteries
AA Batteries
×1
Buzzer
Buzzer
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Voltage Regulator
×1

Software apps and online services

Blueterm

Story

Read more

Custom parts and enclosures

hc-sr04-tut-2_0AWG4Hylxs.png

Schematics

hc-sr04-tut-2_ftOTwTS5FV.png

Code

Ultrasonic sensor

Arduino
const int trigPin = 2;

const int echoPin = 4;



void setup() {

  // initialize serial communication:

  Serial.begin(9600);

}



void loop()

{

  // establish variables for duration of the ping, 

  // and the distance result in inches and centimeters:

  long duration, inches, cm;



  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.

  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:

  pinMode(trigPin, OUTPUT);

  digitalWrite(trigPin, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);



  // Read the signal from the sensor: a HIGH pulse whose

  // duration is the time (in microseconds) from the sending

  // of the ping to the reception of its echo off of an object.

  pinMode(echoPin, INPUT);

  duration = pulseIn(echoPin, HIGH);



  // convert the time into a distance

  inches = microsecondsToInches(duration);

  cm = microsecondsToCentimeters(duration);

  

  Serial.print(inches);

  Serial.print("in, ");

  Serial.print(cm);

  Serial.print("cm");

  Serial.println();

  

  delay(100);

}



long microsecondsToInches(long microseconds)

{

  // According to Parallax's datasheet for the PING))), there are

  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per

  // second).  This gives the distance travelled by the ping, outbound

  // and return, so we divide by 2 to get the distance of the obstacle.

  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf

  return microseconds / 74 / 2;

}



long microsecondsToCentimeters(long microseconds)

{

  // The speed of sound is 340 m/s or 29 microseconds per centimeter.

  // The ping travels out and back, so to find the distance of the

  // object we take half of the distance travelled.

  return microseconds / 29 / 2;

}

GPS

Arduino
 #include <string.h>
 #include <ctype.h>
 int ledPin = 13;                  // LED test pin
 int rxPin = 0;                    // RX PIN 
 int txPin = 1;                    // TX TX
 int byteGPS=-1;
 char linea[300] = "";
 char comandoGPR[7] = "$GPRMC";
 int cont=0;
 int bien=0;
 int conta=0;
 int indices[13];
 void setup() {
   pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   Serial.begin(4800);
   for (int i=0;i<300;i++){       // Initialize a buffer for received data
     linea[i]=' ';
   }   
 }
 void loop() {
   digitalWrite(ledPin, HIGH);
   byteGPS=Serial.read();         // Read a byte of the serial port
   if (byteGPS == -1) {           // See if the port is empty yet
     delay(100); 
   } else {
     // note: there is a potential buffer overflow here!
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     conta++;                      
     Serial.print(byteGPS, BYTE); 
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
       // note: the actual end of transmission is <CR><LF> (i.e. 0x13 0x10)
       digitalWrite(ledPin, LOW); 
       cont=0;
       bien=0;
       // The following for loop starts at 1, because this code is clowny and the first byte is the <LF> (0x10) from the previous transmission.
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
           bien++;
         }
       }
       if(bien==6){               // If yes, continue and process the data
         for (int i=0;i<300;i++){
           if (linea[i]==','){    // check for the position of the  "," separator
             // note: again, there is a potential buffer overflow here!
             indices[cont]=i;
             cont++;
           }
           if (linea[i]=='*'){    // ... and the "*"
             indices[12]=i;
             cont++;
           }
         }
         Serial.println("");      // ... and write to the serial port
         Serial.println("");
         Serial.println("---------------");
         for (int i=0;i<12;i++){
           switch(i){
             case 0 :Serial.print("Time in UTC (HhMmSs): ");break;
             case 1 :Serial.print("Status (A=OK,V=KO): ");break;
             case 2 :Serial.print("Latitude: ");break;
             case 3 :Serial.print("Direction (N/S): ");break;
             case 4 :Serial.print("Longitude: ");break;
             case 5 :Serial.print("Direction (E/W): ");break;
             case 6 :Serial.print("Velocity in knots: ");break;
             case 7 :Serial.print("Heading in degrees: ");break;
             case 8 :Serial.print("Date UTC (DdMmAa): ");break;
             case 9 :Serial.print("Magnetic degrees: ");break;
             case 10 :Serial.print("(E/W): ");break;
             case 11 :Serial.print("Mode: ");break;
             case 12 :Serial.print("Checksum: ");break;
           }
           for (int j=indices[i];j<(indices[i+1]-1);j++){
             Serial.print(linea[j+1]); 
           }
           Serial.println("");
         }
         Serial.println("---------------");
       }
       conta=0;                    // Reset the buffer
       for (int i=0;i<300;i++){    //  
         linea[i]=' ';             
       }                 
     }
   }
 }

Pedoaccelero

Arduino
#include <SoftwareSerial.h>
char junk;
String inputString="";
const int xpin=A2;
int ypin=A3;
int zpin=A4;
int powerpin=A0;
int gnd=A1;
float threshhold=80.0;
float xval[100]={0};
float yval[100]={0};
float zval[100]={0};
float xavg;
float yavg;
float zavg;
float calories;
SoftwareSerial BTserial(10, 11); 
int steps,flag=0;
void setup()
{
Serial.begin(9600);
BTserial.begin(9600);
pinMode(powerpin,OUTPUT);
pinMode(gnd,OUTPUT);
pinMode(8,OUTPUT);
digitalWrite(powerpin,HIGH);
digitalWrite(gnd,LOW);
calibrate();
}
void loop()
{
  digitalWrite(8,HIGH);
  int acc=0;
float totvect[100]={0};
float totave[100]={0};
float xaccl[100]={0};
float yaccl[100]={0};
float zaccl[100]={0};
for (int i=0;i<100;i++)
{
xaccl[i]=float(analogRead(xpin));
delay(1);
yaccl[i]=float(analogRead(ypin));
delay(1);
zaccl[i]=float(analogRead(zpin));
delay(1);
totvect[i] = sqrt(((xaccl[i]-xavg)* (xaccl[i]-xavg))+ ((yaccl[i] - yavg)*(yaccl[i] - yavg)) + ((zval[i] - zavg)*(zval[i] - zavg)));
totave[i] = (totvect[i] + totvect[i-1]) / 2 ;
Serial.println(totave[i]);
//BTserial.write(totave[i]);
delay(200);
if (totave[i]>threshhold && flag==0)
{
  steps=steps+1;
  flag=1; 
}
 else if (totave[i] > threshhold && flag==1)
{
 
}
  if (totave[i] <threshhold  && flag==1)
  {flag=0;}
  Serial.println('\n');
  Serial.print("steps=");
 Serial.println(steps);
BTserial.print("steps=");
BTserial.print(steps);
BTserial.println('\n');
calories=0.063*steps;
Serial.println(calories);
BTserial.print("calories=");
BTserial.print(calories);
BTserial.println('\n');
}
delay(1000);
}
void calibrate()
{
digitalWrite(13,HIGH);
  float sum=0;
  float sum1=0;
  float sum2=0;
for (int i=0;i<100;i++)
{
xval[i]=float(analogRead(xpin));

sum=xval[i]+sum;
}
delay(100);
xavg=sum/100.0;

Serial.println(xavg);

for (int j=0;j<100;j++)
{
xval[j]=float(analogRead(xpin));

sum1=xval[j]+sum1;
}
yavg=sum1/100.0;

Serial.println(yavg);
delay(100);
for (int i=0;i<100;i++)
{
zval[i]=float(analogRead(zpin));

sum2=zval[i]+sum2;
}
zavg=sum2/100.0;
delay(100);
Serial.println(zavg);


}

  

Credits

Katta Rishabh
1 project • 1 follower
Am studying engineering in R.V cllg of engineering
Contact
Thanks to K V Manjunath Reddy and Sumit Jogalekar.

Comments

Please log in or sign up to comment.