DIY-How to make Automatic Straw Dispenser Machine



Flow chart




Hardware

1. Arduino UNO/ NANO
2. Mico servo SG90
3. TCRT5000 Infrared Reflective Sensor Module
4. Wires


Arduino Sketch

#include <Servo.h>

#define sensor1_pin 7 // ir sensor module

Servo servo1;

void setup(){

servo1.attach(8);
pinMode( sensor1_pin , INPUT);

servo1.write(0);
delay(3000);

}

void loop(){
    int val = digitalRead( sensor1_pin );

   if( val == LOW ){
      servo1.write(75);
      delay(1000);
      servo1.write(0);
      delay(1000);
   }

}

ความคิดเห็น