Things used in this project

Hardware components:
Ard nano
Arduino Nano R3
×1
11026 02
Jumper wires (generic)
×1
Servo (generic)
×1
09264 1
RGB Diffused Common Cathode
×1
181 02
Adafruit Standard LCD - 16x2 White on Blue
×1
Software apps and online services:
Ide web
Arduino IDE
10
Microsoft Windows 10 IoT Core

Code

thenanobarrierArduino
//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

Girl
Bogdan F
1 project • 2 followers
H3llo friend!
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login