bdan
Published

LEGO Automatic Car/People Barrier

A little project done at an IoT hackathon. The whole idea was that people who are always on time should be rewarded for their punctuality.

BeginnerShowcase (no instructions)5 hours1,287
LEGO Automatic Car/People Barrier

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Servos (Tower Pro MG996R)
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1

Software apps and online services

Arduino IDE
Arduino IDE
Windows 10 IoT Core
Microsoft Windows 10 IoT Core

Story

Read more

Code

thenanobarrier

Arduino
//3 - 5 noiembrie 2017
//Florea Bogdan

//libraries included
#include <Servo.h>

//definire variabile pentru servo si led RGB
Servo myservo;
int rPin = 11;
int gPin = 10;
int bPin = 9;
int pos = 0;
int buzzer = 5;

// DONT COPY AND PASTE
// CHECK ALWAYS YOUR PINS
void setup() {
  // initializare componente
  pinMode(rPin, OUTPUT); //red 
  pinMode(gPin, OUTPUT); //green
  pinMode(bPin, OUTPUT); //blue
  myservo.attach(6); //micro servo-motor
  pinMode(buzzer, OUTPUT); //added buzzer
  Serial.begin(9600);
}
//
//WE have no problems here

void loop() {
  
  // put your main code here, to run repeatedly:
  
  Serial.println("Bariera inchisa!");
  myservo.write(0); //bariera inchisa
  setColor(255, 0, 0); // rosu
  delay(4000);
  
  Serial.println("Bariera deschisa!");
  tone(buzzer, 500);
  for (int j = 0; j < 91; j++)
  {
    myservo.write(j); //bariera openh
    delay(5);  
  }
  
  setColor(0, 255, 0); //green ptr 2.5 secunde
  delay(2500);
  noTone(buzzer);
  Serial.println("Bariera se intoarce");
  setColor(255, 0, 255); //yellow
  for (int i = 90; i >= 0; i--)
  {
    myservo.write(i);
    delay(20);
  }
}
// final


// functie pentru setare culoare RGB LED
void setColor(int red, int green, int blue)
{ //setare culoare led RGB
  analogWrite(rPin, red);
  analogWrite(gPin, green);
  analogWrite(bPin, blue);
}

Credits

bdan

bdan

6 projects • 7 followers
Hi! Welcome to my profile. Right now studying Arduino and Tkinter library for medical projects.

Comments