Loading...

level crossing


level crossing this is one of my project name :-(BLE)level_crossing


material needed:-

  • Arduino UNO(i used arduino mega)
  • HC-05 (blutooth reciver)
  • servo with attachments
  • jumper wire
  • battery
  • bi-color led (red & green)
  • a small box
  • some nuts and bolt
  • a thin stick
  • smartphone



instructions:-


  • first connect the HC-05 to your arduino


    • vcc = 5v
    • gnd = gnd
    • tx = rx
    • rx = tx
  • _________________________________________________________________________________________

  • then connect the servo to your arduino


    • yellow to digital pin-9
    • red to positive of battry
    • brown/black to negitive of battry and ground of arduino
  • _________________________________________________________________________________________

  • connect your bi-color led


    connect the red anode pin to digital pin-13
    connect the green anode pin to digital pin-12hyuu
    connect the cathode pin to ground pin
  • _________________________________________________________________________________________

  • fit (servo & bi-color led) on a box using screw
  • _________________________________________________________________________________________
  • upload the code on the arduino
  • /*
     LEVEL CROSING over bluetooth 
     BY AREEB-UR-RUB
     WEBSITE :-  http://areeburrub.page.tl
     */
    //
    #include <Servo.h>
    
    Servo myservo1;// create servo object to control a servo
                  // twelve servo objects can be created on most boards
    
    void setup() {//setup code start here
    
     Serial.begin(9600);//Initialize serial port
       myservo1.attach(9);// attaches the servo on pin 9 to the servo object
       pinMode(13,OUTPUT);//set pin number 13 for RED light 
       pinMode(12,OUTPUT);//set pin number 12 for GREEN light 
    
       //I am using a bi-color LED 
      //so by merging green and red i got a yellowish color 
    
    }//setup code end here here
    void loop() {//loop code start here
      
      int s = Serial.read();// read the oldest byte in the serial buffer
      //----------------------OPEN_CODE_START_HERE---------------------------------
      if (s=='o')//if serial read letter 'o' 
      {
        Serial.println("opened the door");//it will print the messege on the serial screen
        //---------- BI-color LED(yellow) -------------
        digitalWrite(13,HIGH);
        digitalWrite(12,HIGH);
        delay(600);//it remain yellow for 600 milli-second 
                  //1000 mili-second is equal to 1 second
        
        //as I am using bi-color led i turend off the red color 
        //---------- BI-color LED(green) -------------    
        // because the door is open the led is green
        digitalWrite(13,LOW); 
        
        //--------------seting the servo angel--------
        myservo1.write(180);//it's angel is 180 degrees
                           //you can change it's angel as your need
     
        delay(15);//time taken to close the door
        }
      //------------------------OPEN_CODE_END_HERE---------------------------------
    
    
      //----------------------CLOSE_CODE_START_HERE---------------------------------    
      else if (s=='c'){  
        Serial.println("closed the door");//it will print the messege on the serial screen
        //---------- BI-color LED(yellow) -------------
        digitalWrite(13,HIGH);
        digitalWrite(12,HIGH);
        delay(600);//it remain yellow for 600 milli-second 
                             //1000 mili-second is equal to 1 second
            
        //as I am using bi-color led i turend off the green color 
        //---------- BI-color LED(RED) -------------    
        // because the door is close the led is red
        digitalWrite(12,LOW); 
    
        //--------------seting the servo angel--------
        myservo1.write(90);//it's angel is 180 degrees
                           //you can change it's angel as your need
     
        delay(15);//time taken to close the door
        }
    //------------------------CLOSE_CODE_END_HERE---------------------------------
      
      }//loop ends here
    
    
    __________________________________________________________________________________________
  • download the applicaton for mobile

    androide contol arduino