Parth Singh
Published

Assited Feedback Navigation

A navigational feedback system for the blind

IntermediateWork in progress670
Assited Feedback Navigation

Story

Read more

Schematics

Schematics

Code

Arduino

Arduino
int analogInPin0 = A0;
int analogOutPin0 = 0; 
int analogInPin1 = A1;
int analogOutPin1 = 1; 
int analogInPin2 = A2;
int analogOutPin2 = 2; 
int analogInPin3 = A3;
int analogOutPin3 = 3; 
int analogInPin4 = A4;
int analogOutPin4 = 4; 
int analogInPin5 = A5;
int analogOutPin5 = 5; 
int analogInPin6 = A6;
int analogOutPin6 = 6; 
int analogInPin7 = A7;
int analogOutPin7 = 7; 
int analogInPin8 = A8;
int analogOutPin8 = 8; 
int analogInPin9 = A9;
int analogOutPin9 = 9; 
int analogInPin10 = A10;
int analogOutPin10 = 10;
int analogInPin11 = A11;
int analogOutPin11 = 11;
int analogInPin12 = A12;
int analogOutPin12 = 12;
int analogInPin13 = A13;
int analogOutPin13 = 13;
int analogInPin14 = A14;
int analogOutPin14 = 14;
int analogInPin15 = A15;
int analogOutPin15 = 15;

int sensorValue0 = 0;        // value read from the IR sensor
int sensorValue1 = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;        // value read from the IR sensor
int sensorValue4 = 0;
int sensorValue5 = 0;
int sensorValue6 = 0;        // value read from the IR sensor
int sensorValue7 = 0;
int sensorValue8 = 0;
int sensorValue9 = 0;        // value read from the IR sensor
int sensorValue10= 0;
int sensorValue11= 0;
int sensorValue12= 0;        // value read from the IR sensor
int sensorValue13= 0;
int sensorValue14= 0;
int sensorValue15= 0;        // value read from the IR sensor

int outputValue0 = 0;        // value output to the Actuator
int outputValue1 = 0;        // value output to the Actuator
int outputValue2 = 0;        // value output to the Actuator
int outputValue3 = 0;        // value output to the Actuator
int outputValue4 = 0;        // value output to the Actuator
int outputValue5 = 0;        // value output to the Actuator
int outputValue6 = 0;        // value output to the Actuator
int outputValue7 = 0;        // value output to the Actuator
int outputValue8 = 0;        // value output to the Actuator
int outputValue9 = 0;        // value output to the Actuator
int outputValue10= 0;        // value output to the Actuator
int outputValue11= 0;        // value output to the Actuator
int outputValue12= 0;        // value output to the Actuator
int outputValue13= 0;        // value output to the Actuator
int outputValue14= 0;        // value output to the Actuator
int outputValue15= 0;        // value output to the Actuator

void setup() 
{
  Serial.begin(9600); 
}

void loop() 
{
  float volts0 = analogRead(analogInPin0)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue0= analogRead(analogInPin0);
  float distance0 = 65*pow(volts0, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk
  
  float volts1 = analogRead(analogInPin1)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue1 = analogRead(analogInPin1);
  float distance1 = 65*pow(volts1, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk
  
  float volts2 = analogRead(analogInPin2)*0.000273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue2 = analogRead(analogInPin2);
  float distance2 = 65*pow(volts2, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts3 = analogRead(analogInPin3)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue3= analogRead(analogInPin3);
  float distance3 = 65*pow(volts3, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts4 = analogRead(analogInPin4)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue4= analogRead(analogInPin4);
  float distance4 = 65*pow(volts4, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts5 = analogRead(analogInPin5)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue5= analogRead(analogInPin5);
  float distance5 = 65*pow(volts5, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts6 = analogRead(analogInPin6)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue6= analogRead(analogInPin6);
  float distance6 = 65*pow(volts6, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts7 = analogRead(analogInPin7)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue7= analogRead(analogInPin7);
  float distance7 = 65*pow(volts7, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts8 = analogRead(analogInPin8)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue8= analogRead(analogInPin8);
  float distance8 = 65*pow(volts8, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts9 = analogRead(analogInPin9)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue9= analogRead(analogInPin9);
  float distance9 = 65*pow(volts9, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts10 = analogRead(analogInPin10)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue10 = analogRead(analogInPin10);
  float distance10 = 65*pow(volts10, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts11 = analogRead(analogInPin11)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue11 = analogRead(analogInPin11);
  float distance11 = 65*pow(volts11, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts12 = analogRead(analogInPin12)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue12 = analogRead(analogInPin12);
  float distance12 = 65*pow(volts12, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts13 = analogRead(analogInPin13)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue13 = analogRead(analogInPin13);
  float distance13 = 65*pow(volts13, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts14 = analogRead(analogInPin14)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue14 = analogRead(analogInPin14);
  float distance14 = 65*pow(volts14, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  float volts15 = analogRead(analogInPin15)*0.00273;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  sensorValue15 = analogRead(analogInPin15);
  float distance15 = 65*pow(volts15, -1.10);          // worked out from graph 65 = theoretical distance / (1/Volts)S - luckylarry.co.uk

  if(distance0>150)
    distance0=150;
  if(distance0<30)
    distance0=30;
  if(distance1>150)
    distance1=150;
  if(distance1<30)
    distance1=30;
  if(distance2>150)
    distance2=150;
  if(distance2<30)
    distance2=30;
  if(distance3>150)
    distance3=150;
  if(distance3<30)
    distance3=30;
  if(distance4>150)
    distance4=150;
  if(distance4<30)
    distance4=30;
  if(distance5>150)
    distance5=150;
  if(distance5<30)
    distance5=30;
  if(distance6>150)
    distance6=150;
  if(distance6<30)
    distance6=30;
  if(distance7>150)
    distance7=150;
  if(distance7<30)
    distance7=30;
  if(distance8>150)
    distance8=150;
  if(distance8<30)
    distance8=30;
  if(distance9>150)
    distance9=150;
  if(distance9<30)
    distance9=30;
  if(distance10>150)
    distance10=150;
  if(distance10<30)
    distance10=30;
  if(distance11>150)
    distance11=150;
  if(distance11<30)
    distance11=30;
  if(distance12>150)
    distance12=150;
  if(distance12<30)
    distance12=30;
  if(distance13>150)
    distance13=150;
  if(distance13<30)
    distance13=30;  
  if(distance14>150)
    distance14=150;
  if(distance14<30)
    distance14=30;
  if(distance15>150)
    distance15=150;
  if(distance15<30)
    distance15=30;
    
    
  outputValue0 = map(distance0, 30, 150, 270, 0);  
  outputValue1 = map(distance1, 30, 150, 270, 0);  
  outputValue2 = map(distance2, 30, 150, 270, 0);  
  outputValue3 = map(distance3, 30, 150, 270, 0);  
  outputValue4 = map(distance4, 30, 150, 270, 0);  
  outputValue5 = map(distance5, 30, 150, 270, 0);  
  outputValue6 = map(distance6, 30, 150, 270, 0);  
  outputValue7 = map(distance7, 30, 150, 270, 0);  
  outputValue8 = map(distance8, 30, 150, 270, 0);  
  outputValue9 = map(distance9, 30, 150, 270, 0);  
  outputValue10= map(distance10, 30, 150, 270, 0);  
  outputValue11= map(distance11, 30, 150, 270, 0);  
  outputValue12= map(distance12, 30, 150, 270, 0);  
  outputValue13= map(distance13, 30, 150, 270, 0);  
  outputValue14= map(distance14, 30, 150, 270, 0);  
  outputValue15= map(distance15, 30, 150, 270, 0);  
  Serial.print("  distance Value0 = " );     
  Serial.print(distance0);  
  Serial.print("  output Value0 = " );     
  Serial.print(outputValue0);  
  Serial.println();
  Serial.print("  distance Value1 = " );     
  Serial.print(distance1);  
  Serial.print("  output Value1 = " );     
  Serial.print(outputValue1);  
  Serial.println();
  Serial.print("  distance Value2 = " );     
  Serial.print(distance2);  
  Serial.print("  output Value2 = " );     
  Serial.print(outputValue2);  
  Serial.print("  distance Value3 = " );     
  Serial.print(distance3);  
  Serial.print("  output Value3 = " );     
  Serial.print(outputValue3);  
  Serial.println();
  Serial.print("  distance Value4 = " );     
  Serial.print(distance4);  
  Serial.print("  output Value4 = " );     
  Serial.print(outputValue4);  
  Serial.println();
  Serial.print("  distance Value5 = " );     
  Serial.print(distance5);  
  Serial.print("  output Value5 = " );     
  Serial.print(outputValue5);  
  Serial.print("  distance Value6 = " );     
  Serial.print(distance6);  
  Serial.print("  output Value6 = " );     
  Serial.print(outputValue6);  
  Serial.println();
  Serial.print("  distance Value7 = " );     
  Serial.print(distance7);  
  Serial.print("  output Value7 = " );     
  Serial.print(outputValue7);  
  Serial.println();
  Serial.print("  distance Value8 = " );     
  Serial.print(distance8);  
  Serial.print("  output Value8 = " );     
  Serial.print(outputValue8);  
  Serial.print("  distance Value9 = " );     
  Serial.print(distance9);  
  Serial.print("  output Value9 = " );     
  Serial.print(outputValue9);  
  Serial.println();
  Serial.print("  distance Value10 = " );     
  Serial.print(distance10);  
  Serial.print("  output Value10 = " );     
  Serial.print(outputValue10);  
  Serial.println();
  Serial.print("  distance Value11 = " );     
  Serial.print(distance11);  
  Serial.print("  output Value11 = " );     
  Serial.print(outputValue11);  
  Serial.print("  distance Value12 = " );     
  Serial.print(distance12);  
  Serial.print("  output Value12 = " );     
  Serial.print(outputValue12);  
  Serial.println();
  Serial.print("  distance Value13 = " );     
  Serial.print(distance13);  
  Serial.print("  output Value13 = " );     
  Serial.print(outputValue13);  
  Serial.println();
  Serial.print("  distance Value14 = " );     
  Serial.print(distance14);  
  Serial.print("  output Value14 = " );     
  Serial.print(outputValue14);  
  Serial.print("  distance Value15 = " );     
  Serial.print(distance15);  
  Serial.print("  output Value15 = " );     
  Serial.print(outputValue15);  
  Serial.println();
  delay(1000);
}
 

BS2

Assembly x86
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM3}

' -----[ I/O Definitions ]-------------------------------------------------

RightServo      PIN     15              ' Right Servo
LeftServo       PIN     14              ' Left Servo
lcd             PIN      8
' -----[ Constants ]-------------------------------------------------------

scalecon1 CON 11000    'Constant for Flex Sensor 1
scalecon2 CON 10850    'Constant for Flex Sensor 2
scalecon3 CON 10800    'Constant for Flex Sensor 3
scalecon4 CON 10800    'Constant for Flex Sensor 4

distcon  CON 2257

' -----[ Variables ]-------------------------------------------------------

fs1 VAR Word
fs2 VAR Word
fs3 VAR Word
fs4 VAR Word
ul1 VAR Word
ir1 VAR Word
ir2 VAR Word
temp VAR Word
pulsecount VAR Word
PS VAR Word
RS VAR Word
LS VAR Word

' -----[ Program Code ]----------------------------------------------------


Main:
DO
DEBUG CLS
GOSUB ld
GOSUB f1
GOSUB f2
GOSUB f3
GOSUB f4
GOSUB ping
GOSUB irs
rs = 750
ls = 750


IF (fs3 < 450) AND (fs4 <450) THEN  'Stop switch
  DO
  IF(fs2 < 450) AND (fs1 < 450) THEN  'Reset the stop switch
    SEROUT lcd, 84, [12]

    SEROUT lcd, 84, [128,"Reset Cleared"]

    DEBUG "reset cleared"
    GOTO main
  ELSE
    DEBUG "reset"
    SEROUT lcd, 84, [12]

    SEROUT lcd, 84, [128,"STOP1 Switch"]

    GOSUB f3
    GOSUB f4
  ENDIF
  LOOP
ENDIF

DO WHILE (ul1 < 20)                     'Obstacle detection
  PULSOUT LeftServo, 750                ' Left Servo Move Pulse Value
  PULSOUT RightServo, 750               ' Right Servo Move Pulse Value
  DEBUG CR,"STOP UltraSonic"
  SEROUT lcd, 84, [12]

  SEROUT lcd, 84, [128,"STOP2 Ultrasonic"]
  'PAUSE 10

  GOSUB ping
 '
LOOP

IF (fs1 > 650) AND (fs1 < 850) THEN     'Speed Control Using FLex Sensor
DEBUG CR,"stationary1"

ELSEIF (fs1 < 650) AND (fs1 > 550) THEN
DEBUG CR,"fw1"
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"Forward"]

LS = 850
RS = 650
PS = 20
GOTO mov

ELSEIF (fs1 < 550) AND (fs1 > 450) THEN
DEBUG CR,"fw2"
LS = 800
RS = 600
PS = 20
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"Forward"]

GOTO mov
ELSEIF (fs1 < 450)   THEN
DEBUG CR,"fw3"
LS = 780
RS = 720
PS = 20
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"Forward"]

GOTO mov
ENDIF

IF (fs2 > 650) AND (fs2 < 850)  THEN    'Speed Control Using FLex Sensor
DEBUG CR,"stationary2"
ELSEIF (fs2 < 650) AND (fs2 > 550)  THEN
DEBUG CR,"bck1"
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"BACK"]

RS = 850
LS = 650
PS = 20
GOTO mov
ELSEIF (fs2 < 550) AND (fs2 > 450)  THEN
DEBUG CR,"bck2"
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"BACK"]

RS = 800
LS = 700
PS = 20
GOTO mov
ELSEIF (fs2 < 450)  THEN
DEBUG CR,"bck3"
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"BACK"]

RS = 780
LS = 720
PS = 20
GOTO mov
ENDIF

IF (fs3 > 650) AND (fs3 < 850)   THEN    'Speed Control Using FLex Sensor
DEBUG CR,"stationary3"
ELSEIF (fs3 < 650) AND (fs3 > 550)   THEN
DEBUG CR,"rw1"
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"RIGHT"]

RS = 650
LS = 650
PS = 20
GOTO mov
ELSEIF (fs3 < 550) AND (fs3 > 450)   THEN
DEBUG CR,"rw2"
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"RIGHT"]

RS = 700
LS = 700
PS = 20
GOTO mov
ELSEIF (fs3 < 450)   THEN
DEBUG CR,"rw3"
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"RIGHT"]

RS = 720
LS = 720
PS = 20
GOTO mov
ENDIF

IF (fs4 > 650) AND (fs4 < 850)   THEN    'Speed Control Using FLex Sensor
DEBUG CR,"stationary4"
ELSEIF (fs4 < 650) AND (fs4 > 550)   THEN
DEBUG CR,"lf1"
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"LEFT"]

RS = 850
LS = 850
PS = 20
GOTO mov
ELSEIF (fs4 < 550) AND (fs4 > 450)   THEN
DEBUG CR,"lf2"
RS = 800
LS = 800
PS = 20
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"LEFT"]

GOTO mov
ELSEIF (fs4 < 450)   THEN
DEBUG CR,"lf3"
SEROUT lcd, 84, [12]

SEROUT lcd, 84, [128,"LEFT"]

RS = 780
LS = 780
ps = 20
GOTO mov
ENDIF

'DEBUG ? fs1,? fs2,? fs3,? fs4
LOOP


'Initialize LCD
LD:
  SEROUT lcd, 84, [22, 12] 'Initialize LCD

  SEROUT lcd, 84, [128,"Glove Controlled", 148, "      BoeBot "]



' *************************************************************************
' * USE THE INFRARED SENSORS TO DETECT CLIFFS                             *
' * WHILE THE PING))) IS FACING FORWARD.                                  *
' *************************************************************************

'IR sensor
IRS:                                    'Check for IR Sensor 1 and 2 HIGH
  DO WHILE(IN6 = 0) OR (IN7 = 0)
  PULSOUT LeftServo, 750                ' Left Servo Move Pulse Value
  PULSOUT RightServo, 750               ' Right Servo Move Pulse Value
  DEBUG CR,"STOP IR Sensor"
  SEROUT lcd, 84, [12]

  SEROUT lcd, 84, [128,"CLIFF DETECTED"]

  LOOP

' *************************************************************************
' * USE THE ULTRASONIC SENSOR TO GET DISTANCE VALUES                      *
' * WHILE THE PING))) IS FACING FORWARD.                                  *
' *************************************************************************

'Ping sensor
PING:                                   'Ultrasonic Distance Measuring
  PULSOUT 4, 5
  PULSIN 4, 1, ul1
  ul1 = distcon ** ul1
  DEBUG CR,DEC3 ul1, " cm"
  RETURN

' *************************************************************************
' * USE THE RCTIME VALUES TO GET THE FLEX SENSOR VALUES                   *
' * WHILE THE PING))) IS FACING FORWARD.                                  *
' *************************************************************************


'Flex Sensor1
F1:
  HIGH 0 'hold pin 0 high to charge capacitor
  PAUSE 1 'charge capacitor for 1/1000 of a second
  RCTIME 0, 1,fs1 'measure discharge time of flex resistor through capacitor
  'fs1=fs1**scalecon1+500
  temp = fs1*/439 - 2572
  fs1 = fs1 - temp
  fs1 = fs1/2

  RETURN

'Flex Sensor2
F2:
  HIGH 1 'hold pin 0 high to charge capacitor
  PAUSE 1 'charge capacitor for 1/1000 of a second
  RCTIME 1, 1,fs2 'measure discharge time of flex resistor through capacitor
'  fs2=fs2**scalecon2+500
  temp = fs2*/439 - 2572
  fs2 = fs2 - temp
  fs2 = fs2/2

  RETURN

'Flex Sensor3
F3:
  HIGH 2 'hold pin 0 high to charge capacitor
  PAUSE 1 'charge capacitor for 1/1000 of a second
  RCTIME 2, 1,fs3 'measure discharge time of flex resistor through capacitor
  'fs3=fs3**scalecon3+500
  temp = fs3*/439 - 2572
  fs3 = fs3 - temp
  fs3 = fs3/2

  RETURN

'Flex Sensor4
F4:
  HIGH 3 'hold pin 0 high to charge capacitor
  PAUSE 1 'charge capacitor for 1/1000 of a second
  RCTIME 3, 1,fs4 'measure discharge time of flex resistor through capacitor
  'fs4=fs4**scalecon4+500
  temp = fs4*/439 - 2572
  fs4 = fs4 - temp
  fs4 = fs4/2

  RETURN

' *************************************************************************
' * USE THE APPROPRIATE PULSOUT VALUES TO MAKE YOUR BOE-BOT MOVE          *
' * WHILE THE PING))) IS FACING FORWARD.                                  *
' *************************************************************************

MOV:                                    ' Send Moving Pulse
  FOR pulseCount = 0 TO 200
   PULSOUT LeftServo, LS               ' Left Servo Move Pulse Value
   PULSOUT RightServo, RS              ' Right Servo Move Pulse Value
'   PAUSE PS                             'Refresh Delay using values passed from speed control
  NEXT
  RETURN

Code

Credits

Parth Singh

Parth Singh

8 projects • 43 followers
M.S. EE with interest in Arduino/Intel Edison/RPi and Tinkering
Thanks to J R Rizzo.

Comments