Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2025:vradulescu:vlad_andrei.voicu [2025/05/24 13:53]
vlad_andrei.voicu
pm:prj2025:vradulescu:vlad_andrei.voicu [2025/05/25 19:34] (current)
vlad_andrei.voicu [Software Design]
Line 14: Line 14:
  
 <note tip> <note tip>
-Aici puneţi tot ce ţine de hardware design: +{{:​pm:​prj2025:​vradulescu:​edit_cafetiera.jpeg?​300|}}
-{{:​pm:​prj2025:​vradulescu:​edit_cafetiera.jpeg?​600|}}+
 </​note>​ </​note>​
  
Line 27: Line 26:
   * algoritmi şi structuri pe care plănuiţi să le implementaţi   * algoritmi şi structuri pe care plănuiţi să le implementaţi
   * (etapa 3) surse şi funcţii implementate   * (etapa 3) surse şi funcţii implementate
 +  * #include <​SoftwareSerial.h>​
 +
 +<code cpp>
 +#include <​SoftwareSerial.h>​
 +#include <​Servo.h>​
 +#include <​LiquidCrystal.h>​
 +
 +// Bluetooth
 +SoftwareSerial mySerial(7, 6); 
 +
 +// LCD
 +LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 +
 +// Servo
 +Servo servoMotor;
 +const int servoPin = 10;
 +
 +// Senzor ultrasonic
 +const int trigPin = 9;
 +const int echoPin = 8;
 +
 +// Configurări
 +const int posInitial = 0;
 +const int posApasare = 150;
 +const int pragNivelApa = 10;  // cm
 +const int delayApasare = 500;
 +
 +void setup() {
 +  mySerial.begin(9600);​
 +  Serial.begin(9600);​
 +
 +  lcd.begin(16,​ 2);
 +  lcd.print("​Sistem pornit"​);​
 +
 +  servoMotor.attach(servoPin);​
 +  servoMotor.write(posInitial);​
 +
 +  pinMode(trigPin,​ OUTPUT);
 +  pinMode(echoPin,​ INPUT);
 +}
 +
 +long masoaraNivelApa() {
 +  digitalWrite(trigPin,​ LOW);
 +  delayMicroseconds(2);​
 +  digitalWrite(trigPin,​ HIGH);
 +  delayMicroseconds(10);​
 +  digitalWrite(trigPin,​ LOW);
 +
 +  long durata = pulseIn(echoPin,​ HIGH);
 +  long distanta = durata * 0.034 / 2;
 +  return distanta;
 +}
 +
 +void loop() {
 +  if (mySerial.available()) {
 +    char comanda = mySerial.read();​
 +    Serial.print("​Comanda primita: ");
 +    Serial.println(comanda);​
 +
 +    lcd.clear();​
 +    lcd.setCursor(0,​ 0);
 +    lcd.print("​Comanda:​ ");
 +    lcd.print(comanda);​
 +
 +    if (comanda == '​1'​) {
 +      long nivelApa = masoaraNivelApa();​
 +
 +      lcd.setCursor(0,​ 1);
 +      lcd.print("​Apa:​ ");
 +      lcd.print(nivelApa);​
 +      lcd.print("​cm"​);​
 +
 +      if (nivelApa > pragNivelApa) {
 +        Serial.println("​Apasare..."​);​
 +        lcd.setCursor(0,​ 1);
 +        lcd.print("​Cafea pornita ​ ");
 +
 +        servoMotor.write(posApasare);​
 +        delay(delayApasare);​
 +        servoMotor.write(posInitial);​
 +      } else {
 +        Serial.println("​Apa insuficienta"​);​
 +        lcd.setCursor(0,​ 1);
 +        lcd.print("​Apa insuficienta"​);​
 +      }
 +    }
 +  }
 +}
 +
 +
 +</​code>​
 +
 +
 </​note>​ </​note>​
  
pm/prj2025/vradulescu/vlad_andrei.voicu.1748084010.txt.gz · Last modified: 2025/05/24 13:53 by vlad_andrei.voicu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0