Zaid Jaber
Published

White Cane Using Attiny

A smart cane using ATtiny85, an ultrasonic sensor, and a buzzer. It detects obstacles and beeps to help visually impaired users avoid them.

IntermediateFull instructions provided424
White Cane Using Attiny

Things used in this project

Hardware components

ATtiny85
Microchip ATtiny85
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Buzzer
Buzzer
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1
Rocker Switch, Non Illuminated
Rocker Switch, Non Illuminated
Similar to this one or a smaller switch
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Circuit Diagram

Code

Main Code

C/C++
This code is for a smart cane project using an ATtiny85 microcontroller, an ultrasonic sensor, and a buzzer. The code detects obstacles in front of the cane and triggers a buzzer to alert the user.
The NewPing library is included to manage the ultrasonic sensor, which measures the distance to obstacles.
The if statement checks if an obstacle is detected within 100 cm and greater than 0 cm.
If true:
The buzzer (connected to pin 0) is turned on (digitalWrite(0, HIGH)).
The buzzer stays on for 500 milliseconds (delay(500)).
The buzzer is then turned off (digitalWrite(0, LOW)).
A delay proportional to the distance (Dis * 7 milliseconds) is introduced before the loop repeats.
If no obstacle is detected or if the distance is greater than 100 cm:
The buzzer stays off (digitalWrite(0, LOW)).
#include <NewPing.h>
/* Trig and echo pins are connected to 1 and 2 on the attiny 
board and to 3 and 4 on the customized designed board*/
#define TRIGGER_PIN 3  // Trigger on 1 or 3
#define ECHO_PIN 4     //Echo on 2 or 4
int Buzzer = 0;

#define MAX_DISTANCE 150

NewPing sonar(TRIGGER_PIN, ECHO_PIN, 200);

void setup() {

  pinMode(0, OUTPUT);
  //Serial.begin (9600);
}

void loop() {

  int Dis = sonar.ping_cm();
  //Serial.println(Dis);
  pinMode(ECHO_PIN, OUTPUT);
  digitalWrite(ECHO_PIN, LOW);
  pinMode(ECHO_PIN, INPUT);
  if (Dis <= 100 && Dis > 0) {
    digitalWrite(0, HIGH);
    delay(500);
    digitalWrite(0, LOW);
    delay(Dis * 7);
  } else {
    digitalWrite(0, LOW);
  }
}

Credits

Zaid Jaber
4 projects • 4 followers
STEM Specialist, Maker, Innovator, Mechatronics Engineer, and Master's in Electrical Engineering. Passionate about innovation and tinkering.
Thanks to Saif Suhimat.

Comments