KEEP YOUR SPACE Hat

by atbindustries225 in Circuits > Arduino

88 Views, 1 Favorites, 0 Comments

KEEP YOUR SPACE Hat

IMG_20250721_133728717 (1).jpg

What is the biggest issue in life? That's right, SAFETY and PERSONAL SPACE! This device is also made to teach beginners about Arduino and C++. It definitely does have practical uses, for example, those that have vision impairment or who are recovering from eye surgery could benefit from this device. The ultrasonic sensor affixed to the hat/helmet emits a warning sound to alert the wearer that they are close to a wall, person, or other objects.

Supplies

IMG_20250721_122616007_HDR.jpg
  1. helmet(funnier option) or hat
  2. Ardurino Nano, or other board
  3. ultrasonic sensor
  4. wires with holes on the end(ribbon cable)
  5. buzzer
  6. battery
  7. soldering iron(optional)
  8. solder(optional)

Assemble

IMG_20250721_123523753_HDR.jpg

The first thing to do is connect everything, keep in mind "d" followed by a number means digital.

Buzzer(positive to d2, Negative to ground)

Ultrasonic sensor(vcc to 5v, trig to d11, echo to d10, ground to ground)

battery(positive to vin, negative to ground)

Please note that you may have to solder the battery on if your not using a bread board, you have to do this with the Nano.


Attaching

IMG_20250721_123747570.jpg

Great now that you have everything attached or soldered, you may use electrical tape to secure it. I found Fun-Tac also works, but its harder to peel of, and may leave oil, would not recommend, but it is an option. You can also use hot glue as it is not a conductor, and it is good at its job(hard to get undone).

Programing

IMG_20250721_123912058_HDR.jpg

First thing is to download Ardurino IDE(link below), then write all the code listed below(I would recommend writing it so you can get a "feel" for the code. Plug your Ardurino into the laptop, and hit upload. I am not going through on how to do everything, but if you get an error code like "board not reconized," or "Nothing found in port," then go to tools on the top, and change board to your board, and change your microchip processor to the correct one, along with the port, probably, com-10. Please check the code before you do this, especially if it gives you a highlighted line. Code below, It is all labeled.


long duration; //Creates a variable with a bigger integer size

int distance;// creates an integer variable


const int trigPin = 11; //establishes the trigger pin as pin 11(can not be changed)

const int echoPin = 10; //establishes the echo pin as pin 10(can not be changed)

const int BuzzerPin =2; //establishes the buzzer pin as pin 2(can not be changed)

void setup() {

// put your setup code here, to run once:

pinMode(trigPin, OUTPUT); // Sets the trigger pin to an output

pinMode(echoPin, INPUT); // Sets the echo pin to an input

pinMode(BuzzerPin, OUTPUT); // Sets the buzzer pin to an output

Serial.begin(115200); // begins a connection to the serial port at 115200 baud


}


void loop() {

// put your main code here, to run repeatedly:

digitalWrite(trigPin,LOW); //Turns sensor off

delayMicroseconds(2); //delays it 2 microseconds

digitalWrite(trigPin, HIGH); //Turns the sensor on

delayMicroseconds(10); // keeps the sensor on for 10 microseconds

digitalWrite(trigPin,LOW); // Turns the sensor off


duration = pulseIn(echoPin, HIGH); // how long the pulse took for it to turn high

distance = duration*0.013/ 2; // finds the distance by multiplying the duration times how much inches sound takes to travel a microsecond

Serial.print("distance: "); // prints what's found in quotations

Serial.println(distance); // Prints the actual distance on the same line above(in inches)


if (distance <= 7){ //if command checks if the distance is less than the specific number

tone(BuzzerPin,2000); // plays buzzer on a high frequency

delay(300); // waits 300 milliseconds

noTone(BuzzerPin); // stops buzzer

} //ends if command



} // ends loop





Attaching It to the Hat

IMG_20250721_133728717.jpg

This part is especially easy, all you have to do is attach it to the hat, go figure. I used tape, to get it on, I used electrical, but you can use any tape, even glue! just do not break any of the connections.

Conclusion

IMG_20250721_124036441.jpg

Thank you for following this lesson, I hope it proved helpful, and taught you a lot, I hope you are inspired to keep learning Arduino code, and making new things. I hope this also inspired the judges, and hope to win. Thank you for reading this Instructable.

CREDITS:

Robonyx's video

My family

ChatGPT, for double checking my code, and google to find how the speed of sound