Time to Buy Food!!

Introduction: Time to Buy Food!!

I can remind you to buy food

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Why I Want to Do This

My mother always forgets to buy orange so I make this to remind her.

Step 2: What We Need

Arduino uno R3 1個

電路試驗版 1個

超音波距離感應器。1個

電阻 1個

燈泡 1個

線 (因人而異)

Step 3: Bread Boards

Step 4: Run a Program

https://create.arduino.cc/editor/JennyLin717/5ef4ca22-ae25-4c82-adf0-d0706d6711e3/preview


int UltrasonicSensorCM(int trigPin, int echoPin) //Ultrasonic Sensor Code Auto Generated Return CM max distance 200
{
long duration;
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(20);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
duration = duration / 59;
if ((duration < 2) || (duration > 200)) return false;
return duration;
}


void setup(){ // put your setup code here, to run once:
digitalWrite( 11 , LOW ); //set ultrasonic sensor trigPin

pinMode( 10 , OUTPUT); // sets the digital pin as output
}

void loop(){ // put your main code here, to run repeatedly:
if ( UltrasonicSensorCM( 11 , 12 ) <10) {
digitalWrite( 10 , LOW ); // sets the digital pin on/off
noTone(8); //stop generating the tone
}
if ( UltrasonicSensorCM( 11 , 12 ) >10) {
digitalWrite( 10 , HIGH ); // sets the digital pin on/off
tone(8, 440, 1000); //buzzer or speaker frequency
}
}

Step 5: How to Work

https://youtu.be/pRDcsejsyQ8

Be the First to Share

    Recommendations

    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest
    • Fix It Contest

      Fix It Contest

    Discussions

    0
    seamster
    seamster

    22 days ago

    Clever idea! : )