Ingeimaks Ingeimaks
Created July 23, 2020

Choose a floor without touching in the elevator - Notouchmak

Use this project in the elevator to choose a floor without touching the keys using an ultrasound sensor, to choose the floor you'll get clos

IntermediateFull instructions provided20 hours111
Choose a floor without touching in the elevator - Notouchmak

Things used in this project

Hardware components

Arduino MKR GSM 1400
Arduino MKR GSM 1400
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×3
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
LED (generic)
LED (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×2

Software apps and online services

Fusion
Autodesk Fusion
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Custom parts and enclosures

File CAD

Schematics

Schematics

Code

Code

C/C++
#include <NewPing.h>
#include <Servo.h>
#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);

#define TRIGGER_PIN  10
#define ECHO_PIN     10
#define MAX_DISTANCE 400

Servo piano_0_1; 
Servo piano_2_3; 
Servo piano_4_A; 

int cm;
int tempo=0;
int piano = 0;
int pos = 90;

int LED_R = 12;
int LED_V = 13;

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
  Serial.begin(115200);
  Serial.println("Ready"); 
  
  lcd.init();
  lcd.backlight();
  lcd.setCursor(3, 0); // Set the cursor on the first column and first row.
  lcd.print("Touch Free"); // Print the string "Hello World!"
  lcd.setCursor(4, 1); //Set the cursor on the third column and the second row (counting starts at 0!).
  lcd.print("Project!");
  piano_0_1.attach(2);
  piano_2_3.attach(3);
  piano_4_A.attach(4);
  delay(3000);
  lcd.clear();
  
}

void loop() {  
  delay(35);
  piano_0_1.write(pos);
  piano_2_3.write(pos);
  piano_4_A.write(pos); 
  digitalWrite(LED_R,HIGH);
  digitalWrite(LED_V,LOW);
  int uS = sonar.ping();  
  cm = sonar.convert_cm(uS); 
  lcd.clear();
  
if (cm<18){

lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Piano = "); // Prints string "Distance" on the LCD
//lcd.print(cm); // Prints the distance value from the sensor

  switch (cm) {
    case 5:   
    case 6:  
      Serial.println("Piano 0");
      Serial.println(tempo);
      lcd.print("0");
      tempo++;
      if(tempo==4){piano_0_1.write(70);pulsante(0);}
      delay(500);
      break;
    case 7:  
    case 8:   
      Serial.println("Piano 1");
      Serial.println(tempo);
      lcd.print("1");
      tempo++;
      if(tempo==4){piano_0_1.write(110);pulsante(1);}
      delay(500);      
      break;
    case 9:    
    case 10: 
      Serial.println("Piano 2");
      Serial.println(tempo);
      lcd.print("2");
      tempo++;
      if(tempo==4){piano_2_3.write(60);pulsante(2);}
      delay(500);      
      break;
    case 11: 
    case 12:   
      Serial.println("Piano 3");
      Serial.println(tempo);
      lcd.print("3");
      tempo++;
      if(tempo==4){piano_2_3.write(110);pulsante(3);}
      delay(500);      
      break;
    case 13: 
    case 14:      
      Serial.println("Piano 4");
      Serial.println(tempo);
      lcd.print("4");
      tempo++;
      if(tempo==6){piano_4_A.write(70);pulsante(4);}
      delay(500);      
      break;
    case 3: 
    case 4:
      lcd.clear();
      lcd.setCursor(0,0);   
      Serial.println("Allarme");
      tempo++;
      if(tempo==4){piano_4_A.write(110);pulsante(5);}
      delay(100);
      lcd.print("Allarme");
      delay(2000);
      Serial.println(tempo);
      break;
  }
if(tempo>10)tempo=0;
delay(10);
}else{
  lcd.clear();
  lcd.setCursor(3,0); // Sets the location at which subsequent text written to the LCD will be displayed
  lcd.print("Touch Free ");  
  delay(2000);
  tempo=0;
  
} 
}

void pulsante(int x){

lcd.clear();
lcd.setCursor(0,0);   
lcd.print("Confermato!");
lcd.setCursor(1,1);
if(x != 5){ 
lcd.print("Piano = ");
lcd.setCursor(9,1);   
lcd.print(x);
digitalWrite(LED_R,LOW);
digitalWrite(LED_V,HIGH);
delay(2000);
}

tempo=0;
loop();  
}

Credits

Ingeimaks Ingeimaks

Ingeimaks Ingeimaks

14 projects • 45 followers
Giovanni Mannara is a Maker. Thanks to Massimo Banzi I have traversed this path of Digital Creator ... I LOVE ARDUINO !!!

Comments