Table of Contents

Water dispenser

Student: Vîrţan Alina-Elena

Grupa: 331CC

Introducere

Ştiai că aproximativ 71% din suprafaţa pământului este repezentată de apă, dar doar 2.5% din apa disponibilă este potabilă? Apa este o resursă vitală, însă noi, oamenii, risipim din neglijenţă cantităţi îngrijorătoare de apă. Dacă am înlocui toate robinetele manuale cu robinete inteligente, care să se deschidă şi să se închida automat, am economisi, în timp, o cantitate considerabilă de apă.

Proiectul are ca scop stoparea risipei de apă potabilă şi presupune construirea unui dozator automat care toarnă cantitatea necesară de apă când plasezi un pahar sub el.

Descriere generală

Dozatorul de apă îşi propune să înlocuiască robinetul manual cu unul inteligent, capabil să se se declanşeze automat.

Principiul care stă la baza dozatorului este unul simplu: automatul se declanşează şi toarnă lichidul când detectează că un pahar este plasat sub rezervor.

Se va folosi senzorul ultrasonic HC-SR04 pentru a detecta dacă un obiect este poziţionat sub dozator. Odată ce detectează obiectul, dozatorul va turna apă şi se va opri când paharul este umplut.

Hardware Design

Lista de piese

Schema electrică

Software Design

Pompa de aer/apă

Modul releu

void setup() {
  // put your setup code here, to run once:
  pinMode(relayPin, OUTPUT);
  ...
}
 
void loop() {
  // put your main code here, to run repeatedly:
  centimeter = readUltrasonicDistance() / 58.00;
  if (centimeter < 15) {
    delay(500);
    centimeter = readUltrasonicDistance() / 58.00;
    if (centimeter < 15) {
      digitalWrite(relayPin, HIGH);
      ...
    } else {
      digitalWrite(relayPin, LOW);
      ...
    }
  } else {
    digitalWrite(relayPin, LOW);
    ...
  }
}

Leduri

Ledul roşu:

Ledul verde:

void setup() {
  // put your setup code here, to run once:
  pinMode(greenLed, OUTPUT);
  pinMode(redLed, OUTPUT);
}
 
void loop() {
  // put your main code here, to run repeatedly:
  centimeter = readUltrasonicDistance() / 58.00;
  if (centimeter < 15) {
    delay(500);
    centimeter = readUltrasonicDistance() / 58.00;
    if (centimeter < 15) {
      .....
      digitalWrite(greenLed, LOW);
      digitalWrite(redLed, HIGH);
    } else {
      .....
      digitalWrite(greenLed, HIGH);
      digitalWrite(redLed, LOW);
    }
  } else {
    .....
    digitalWrite(greenLed, HIGH);
    digitalWrite(redLed, LOW);
  }
}

Senzor ultrasonic

/* Ultrasonic Module pins 
 * 
 * triggerPin: 10 microsecond high pulse causes sharp sound , wait 50 us
 * echoPin: Width of high pulse indicates distance
 */
const int triggerPin = 11;
const int echoPin = 12;
 
 
// ultrasonic sensor distance
int centimeter = 0;
 
long readUltrasonicDistance() {
  pinMode(triggerPin, OUTPUT);  // Clear the trigger
  digitalWrite(triggerPin, LOW);
  delayMicroseconds(2);
  digitalWrite(triggerPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin, LOW);
  pinMode(echoPin, INPUT);
  return pulseIn(echoPin, HIGH);
}

Buzzer

  // Pink Panther theme
 
int melody[] = {
  REST,2, REST,4, REST,8, NOTE_DS4,8, 
  NOTE_E4,-4, REST,8, NOTE_FS4,8, NOTE_G4,-4, REST,8, NOTE_DS4,8,
  NOTE_E4,-8, NOTE_FS4,8,  NOTE_G4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_E4,8, NOTE_G4,-8, NOTE_B4,8,   
  NOTE_AS4,2, NOTE_A4,-16, NOTE_G4,-16, NOTE_E4,-16, NOTE_D4,-16, 
  NOTE_E4,2, REST,4, REST,8, NOTE_DS4,4,
 
  NOTE_E4,-4, REST,8, NOTE_FS4,8, NOTE_G4,-4, REST,8, NOTE_DS4,8,
  NOTE_E4,-8, NOTE_FS4,8,  NOTE_G4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_G4,8, NOTE_B4,-8, NOTE_E5,8,
  NOTE_DS5,1,   
  NOTE_D5,2, REST,4, REST,8, NOTE_DS4,8, 
  NOTE_E4,-4, REST,8, NOTE_FS4,8, NOTE_G4,-4, REST,8, NOTE_DS4,8,
  NOTE_E4,-8, NOTE_FS4,8,  NOTE_G4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_E4,8, NOTE_G4,-8, NOTE_B4,8,   
 
  NOTE_AS4,2, NOTE_A4,-16, NOTE_G4,-16, NOTE_E4,-16, NOTE_D4,-16, 
  NOTE_E4,-4, REST,4,
  REST,4, NOTE_E5,-8, NOTE_D5,8, NOTE_B4,-8, NOTE_A4,8, NOTE_G4,-8, NOTE_E4,-8,
  NOTE_AS4,16, NOTE_A4,-8, NOTE_AS4,16, NOTE_A4,-8, NOTE_AS4,16, NOTE_A4,-8, NOTE_AS4,16, NOTE_A4,-8,   
  NOTE_G4,-16, NOTE_E4,-16, NOTE_D4,-16, NOTE_E4,16, NOTE_E4,16, NOTE_E4,2,
 
};
 
void loop() {
      // iterate over the notes of the melody.
      for (int thisNote = 0; thisNote < notes * 2 && centimeter < 15; thisNote = thisNote + 2) {
        // calculates the duration of each note
        divider = melody[thisNote + 1];
        if (divider > 0) {
          // regular note, just proceed
          noteDuration = (wholenote) / divider;
        } else if (divider < 0) {
          // dotted notes are represented with negative durations!!
          noteDuration = (wholenote) / abs(divider);
          noteDuration *= 1.5; // increases the duration in half for dotted notes
        }
 
        // we only play the note for 95% of the duration, leaving 5% as a pause
        tone(buzzer, melody[thisNote], noteDuration * 0.95);
 
        // Wait for the specief duration before playing the next note.
        delay(noteDuration);
 
        // stop the waveform generation before the next note.
        noTone(buzzer);
}

Rezultate obţinute

Prima variantă funcţională de legare a componentelor pe plăcuţă. În acest stadiu, testam doar funcţionalitatea, fără să construiesc faţada dozatorului.

Ulterior, am regândit aranjarea componentelor. Am legat totul într-un mod mai aerisit. În acest stadiu, începusem deja să construiesc faţada dozatorului şi îmi puneam problema cum o să lipesc componentele în interiorul cutiei.

În final, acesta este rezultatul faţadei dozatorului. În interior, se află componentele lipite de o parte şi de alta a pereţilor dozatorului.

Demo

Download

Cod sursa: water_dispenser.zip

Jurnal

Concluzii

Bibliografie