Magic Spacer

Introduction: Magic Spacer

The current guide supports who have near vision equity or vision promotion under long working condition. This device can help you promote better eyes and learn some electrical engineering in the process. The distance detector uses its ultrasonic detector to detect the range within your computer and your chest. The closer, the worse your vision will progress. The further, the better or promotion your vision gets. The device warns you of any close actions and remind you of the distance kept between your eyes and your computer.

Modified website from: https://www.instructables.com/id/Ultrasonic-Distance-Sensor-Arduino-Tinkercad/

Step 1: Step 1: Materials

1 Arduino Leonardo

1 Bread board

1 Ultrasonic sensor

2 Green LEDs

2 Yellow LEDs

2 White LEDs

A lot of Jumpwires

Step 2: Step 2: Setup

Setup according to the layout and you'll be fine.

Be aware:

LED 1 - pin 8

LED 2 - pin 9

LED 3 - pin 10

LED 4 - pin 11

LED 5 - pin 12

LED 6 - pin 13

DISCLAIMER:

It's highly recommended to do some research about Arduino before attempting to try this project, be sure to check out some other basic designs and online tutorials about LEDs and ultrasonic sensors.

Change:

-increase the LED amount

Step 3: Step 3: the Code

#define trigPin 7
#define echoPin 6

#define led 13

#define led2 12

#define led3 11 改:把LED3 加上

#define led4 10 改:把LED4 加上

#define led5 9 改:把LED5 加上

#define led6 8 改:把LED6 加上

void setup() {

Serial.begin (9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(led, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led3, OUTPUT);

pinMode(led4, OUTPUT);

pinMode(led5, OUTPUT);

pinMode(led6, OUTPUT);

pinMode(buzzer, OUTPUT);

}

void loop() {

long duration, distance;

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

if (distance <= 30) {

digitalWrite(led, HIGH);

}

else {

digitalWrite(led,LOW);

}

if (distance < 25) {

digitalWrite(led2, HIGH);

}

else {

digitalWrite(led2, LOW);

}

if (distance < 20) {

digitalWrite(led3, HIGH);

}

else {

digitalWrite(led3, LOW);

}

if (distance < 15) {

digitalWrite(led4, HIGH);

}

else {

digitalWrite(led4,LOW);

}

if (distance < 10) {

digitalWrite(led5, HIGH);

}

else {

digitalWrite(led5,LOW);

}

if (distance < 5)

{

digitalWrite(led6, HIGH);

}

else { digitalWrite(led6,LOW);

}

if (distance > 30 || distance <= 0)

{

Serial.println("Out of range");

} else {

Serial.print(distance);

Serial.println(" cm");

}

delay(500);

}

改:把tone刪掉

改: 1. 3 led - 6 led, 更亮更清楚

改:除去聲音,太吵

Reference to 網站 - https://create.arduino.cc/editor/ian_997/b28fcb4a-efd0-4910-b41b-6736213d439f

Step 4: Step 4: Try It!

Try it yourself! The LED will light up little by little, the closer you get the lighter the LED get. try to keep the LED low on light, to promote your vision! Remember to place it in the front of your chest and between your desktop!

Video coming soon!

Be the First to Share

    Recommendations

    • Halloween Contest

      Halloween Contest
    • Retro Tech Challenge

      Retro Tech Challenge
    • Organization Contest

      Organization Contest

    Comments

    0
    Elaina M
    Elaina M

    1 year ago

    Very cool ! It's great to see projects inspiring other projects. Thanks for documenting and sharing your work. You should let the other author know you made a version of their project in the "I made it" section of their instructable. I'm sure they'd love to see this and hear your feedback if you did anything different :)