This shows you the differences between two versions of the page.
|
pm:prj2022:apredescu:alarmclock [2022/05/27 21:30] irinel.vlad [Bibliografie/Resurse] |
pm:prj2022:apredescu:alarmclock [2022/06/02 11:32] (current) irinel.vlad [Bibliografie/Resurse] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Alarm Clock ====== | + | ====== Parking Sensor ====== |
| ===== Introducere ===== | ===== Introducere ===== | ||
| <note tip> | <note tip> | ||
| Prezentarea pe scurt a proiectului vostru: | Prezentarea pe scurt a proiectului vostru: | ||
| - | * ceas cu alarma bazat pe o placa de dezvoltare Arduino Uno | + | * un senzor ultrasonic care măsoară distanța și graficul bară cu LED-uri se va aprinde în funcție de distanța noastră de la senzor |
| - | * functiile ceas si alarma | + | * poate funcționa ca un senzor de parcare |
| - | * nevoia de a avea un device simplu pentru alarma | + | * nevoia de ajutor la parcarea cu spatele |
| - | * elimina nevoia de a avea telefonul aproape in fiecare dimineata | + | * asistenta la parcare pentru a evita orice fel de contact |
| </note> | </note> | ||
| ===== Descriere generală ===== | ===== Descriere generală ===== | ||
| <note tip> | <note tip> | ||
| - | {{:pm:prj2022:apredescu:alarm_clock_scheme.png?700|}} | + | |
| </note> | </note> | ||
| Line 19: | Line 19: | ||
| <note tip> | <note tip> | ||
| Aici puneţi tot ce ţine de hardware design: | Aici puneţi tot ce ţine de hardware design: | ||
| - | * Arduino UNO – 1 | + | * Arduino UNO |
| - | * DS 1307 RTC Module – 1 | + | * 1x 74HC595 - registru de deplasare pe 8 biți |
| - | * Push Buttons – 3 | + | * 1x Breadboard |
| - | * 16X2 LCD Display – 1 | + | * LED-uri 8x (de exemplu: 3x roșu, 3x galben, 2x verde) |
| - | * Buzzer – 1 | + | * Rezistențe de 9 Ohm 220 Ohm |
| - | * 10 KΩ – 2 | + | * 1x Buzzer |
| - | * 10 KΩ POT – 1 | + | * 1x senzor ultrasonic (de exemplu: HC-SR04) |
| - | {{:pm:prj2022:apredescu:arduino-alarm-clock.jpg?650|}} | + | * Jumper Wires |
| + | {{:pm:prj2022:apredescu:1navtakqv8ciwhrao31gncyqgk9vi_h1l.png?300|}} | ||
| </note> | </note> | ||
| Line 33: | Line 34: | ||
| <note tip> | <note tip> | ||
| - | * Arduino IDE | ||
| - | * Additional Libraries: Wire/EEPROM/RTClib/LiquidCrystal | ||
| <code cvp> | <code cvp> | ||
| - | #include <Wire.h> | + | int tonePin = 4; //Tone - Red Jumper |
| - | #include<EEPROM.h> | + | int trigPin = 9; //Trig - violet Jumper |
| - | #include <RTClib.h> | + | int echoPin = 10; //Echo - yellow Jumper |
| - | #include <LiquidCrystal.h> | + | int clockPin = 11; //IC Pin 11 - white Jumper |
| - | #define buz 11 | + | int latchPin = 12; //IC Pin 12 - Blue Jumper |
| + | int dataPin = 13; //IC Pin 14 - Green Jumper | ||
| - | LiquidCrystal lcd(2, 3, 4, 5, 6, 7); | + | byte possible_patterns[9] = { |
| - | RTC_DS1307 RTC; | + | B00000000, |
| + | B00000001, | ||
| + | B00000011, | ||
| + | B00000111, | ||
| + | B00001111, | ||
| + | B00011111, | ||
| + | B00111111, | ||
| + | B01111111, | ||
| + | B11111111, | ||
| + | }; | ||
| + | int proximity=0; | ||
| + | int duration; | ||
| + | int distance; | ||
| - | int tmp,Inc,hor,mIn,add=11; | + | void setup() { |
| - | int set=8; | + | //Serial Port |
| - | int cge=9; | + | Serial.begin (9600); |
| - | int mod=10; | + | |
| - | int off=0; | + | |
| - | int Hor,Min,Sec; | + | |
| - | void time() | + | pinMode(trigPin, OUTPUT); |
| - | { | + | pinMode(echoPin, INPUT); |
| - | int tmp=1,mins=0,hors=0,secs=0; | + | pinMode(clockPin, OUTPUT); |
| - | while(tmp==1) | + | pinMode(latchPin, OUTPUT); |
| - | { | + | pinMode(dataPin, OUTPUT); |
| - | off=0; | + | pinMode(tonePin, OUTPUT); |
| - | + | } | |
| - | if(digitalRead(cge)==0) | + | |
| - | { | + | |
| - | Hor++; | + | |
| - | + | ||
| - | if(Hor==24) | + | |
| - | { | + | |
| - | Hor=0; | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | lcd.clear(); | + | |
| - | lcd.setCursor(0,0); | + | |
| - | lcd.print("Set Alarm Time "); | + | |
| - | lcd.setCursor(0,1); | + | void loop() { |
| - | + | digitalWrite(latchPin, LOW); | |
| - | if(Hor<=9) | + | digitalWrite(trigPin, HIGH); |
| - | lcd.print("0"); | + | delayMicroseconds(1000); |
| - | lcd.print(Hor); | + | digitalWrite(trigPin, LOW); |
| - | lcd.print(":"); | + | duration = pulseIn(echoPin, HIGH); |
| - | lcd.print(Min); | + | distance = (duration/2) / 29.1; |
| - | lcd.print(":"); | + | |
| - | lcd.print(Sec); | + | |
| - | delay(200); | + | |
| - | lcd.setCursor(0,1); | + | |
| - | lcd.print(" "); | + | |
| - | lcd.print(":"); | + | |
| - | lcd.print(Min); | + | |
| - | lcd.print(":"); | + | |
| - | lcd.print(Sec); | + | |
| - | delay(200); | + | |
| - | + | ||
| - | if(digitalRead(set)==0) | + | |
| - | { | + | |
| - | hor=Hor; | + | |
| - | EEPROM.write(add++,hor); | + | |
| - | tmp=2; | + | |
| - | + | ||
| - | while(digitalRead(set)==0); | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | while(tmp==2) | + | |
| - | { | + | |
| - | if(digitalRead(cge)==0) | + | |
| - | { | + | |
| - | Min++; | + | |
| - | if(Min==60) | + | |
| - | {Min=0;} | + | |
| - | } | + | |
| - | lcd.setCursor(0,1); | + | |
| - | lcd.print(Hor); | + | |
| - | lcd.print(":"); | + | |
| - | + | ||
| - | if(Min<=9) | + | |
| - | lcd.print("0"); | + | |
| - | lcd.print(Min); | + | |
| - | lcd.print(":"); | + | |
| - | lcd.print(Sec); | + | |
| - | lcd.print(" "); | + | |
| - | delay(200); | + | |
| - | lcd.setCursor(0,1); | + | |
| - | lcd.print(Hor); | + | |
| - | lcd.print(":"); | + | |
| - | lcd.print(" "); | + | |
| - | lcd.print(":"); | + | |
| - | lcd.print(Sec); | + | |
| - | lcd.print(" "); | + | |
| - | delay(200); | + | |
| - | + | ||
| - | if(digitalRead(set)==0) | + | |
| - | { | + | |
| - | mIn=Min; | + | |
| - | EEPROM.write(add++, mIn); | + | |
| - | tmp=0; | + | |
| - | + | ||
| - | while(digitalRead(set)==0); | + | |
| - | } | + | |
| - | } | + | |
| - | off=1; | + | |
| - | delay(10); | + | |
| - | } | + | |
| - | void Buz() | + | /*if (distance >= 45 || distance <= 0){ |
| - | { | + | Serial.println("Out of range"); |
| - | + | ||
| - | if(digitalRead(set)==0) | + | |
| - | off=0; | + | |
| - | if(off==1) | + | |
| - | { | + | |
| - | digitalWrite(buz,HIGH); | + | |
| - | delay(500); | + | |
| - | + | ||
| - | digitalWrite(buz, LOW); | + | |
| - | delay(500); | + | |
| } | } | ||
| - | } | + | else { |
| + | Serial.print(distance); | ||
| + | Serial.println(" cm"); | ||
| + | }*/ | ||
| - | void TimeCheck() | + | proximity=map(distance, 0, 45, 8, 0); |
| - | { | + | //Serial.println(proximity); |
| - | int tem[17]; | + | |
| - | + | if (proximity <= 0){ | |
| - | for(int i=11;i<17;i++) | + | proximity=0; |
| - | { | + | } |
| - | tem[i]=EEPROM.read(i); | + | else if (proximity >= 3 && proximity <= 4){ |
| + | tone(tonePin, 200000, 200); | ||
| + | } | ||
| + | else if (proximity >= 5 && proximity <= 6){ | ||
| + | tone(tonePin,5000, 200); | ||
| } | } | ||
| + | else if (proximity >= 7 && proximity <= 8){ | ||
| + | tone(tonePin, 1000, 200); | ||
| + | } | ||
| + | shiftOut(dataPin, clockPin, MSBFIRST, possible_patterns[proximity]); | ||
| + | digitalWrite(latchPin, HIGH); | ||
| + | |||
| | | ||
| - | if(Hor == tem[11] && Min == tem[12] && off==1) | ||
| - | { | ||
| - | add=11; | ||
| - | Buz(); | ||
| - | Buz(); | ||
| - | lcd.clear(); | ||
| - | lcd.print("alarm..........."); | ||
| - | lcd.setCursor(0,1); | ||
| - | lcd.print("...........alarm"); | ||
| - | Buz(); | ||
| - | Buz(); | ||
| - | } | ||
| - | } | ||
| - | |||
| - | void setup() | ||
| - | { | ||
| - | Wire.begin(); | ||
| - | RTC.begin(); | ||
| - | lcd.begin(16,2); | ||
| - | pinMode(cge, INPUT); | ||
| - | pinMode(set, INPUT); | ||
| - | pinMode(mod, INPUT); | ||
| - | pinMode(buz, OUTPUT); | ||
| - | digitalWrite(set, HIGH); | ||
| - | digitalWrite(mod, HIGH); | ||
| - | digitalWrite(cge, HIGH); | ||
| - | |||
| - | lcd.setCursor(0,1); | ||
| - | lcd.print(" Alarm Clock "); | ||
| - | delay(2000); | ||
| - | | ||
| - | if(!RTC.isrunning()) | ||
| - | { | ||
| - | RTC.adjust(DateTime(__DATE__,__TIME__)); | ||
| - | } | ||
| - | } | ||
| - | |||
| - | void loop() | ||
| - | { | ||
| - | DateTime now = RTC.now(); | ||
| - | |||
| - | if(digitalRead(mod) == 0) | ||
| - | { | ||
| - | current(); | ||
| - | time(); | ||
| - | delay(1000); | ||
| - | lcd.clear(); | ||
| - | lcd.setCursor(0,0); | ||
| - | lcd.print(" Alarm On"); | ||
| - | delay(2000); | ||
| - | } | ||
| - | |||
| - | lcd.clear(); | ||
| - | lcd.setCursor(0,0); | ||
| - | lcd.print("Time:"); | ||
| - | lcd.setCursor(6,0); | ||
| - | Hor=now.hour(),DEC; | ||
| - | |||
| - | if(Hor<=9) | ||
| - | { | ||
| - | lcd.print("0"); | ||
| - | lcd.print(Hor=now.hour(),DEC); | ||
| - | } | ||
| - | else | ||
| - | lcd.print(Hor=now.hour(),DEC); | ||
| - | lcd.print(":"); | ||
| - | Min=now.minute(),DEC; | ||
| - | |||
| - | if(Min<=9) | ||
| - | { | ||
| - | lcd.print("0"); | ||
| - | lcd.print(Min=now.minute(),DEC); | ||
| - | } | ||
| - | else | ||
| - | lcd.print(Min=now.minute(),DEC); | ||
| - | |||
| - | lcd.print(":"); | ||
| - | Sec=now.second(),DEC; | ||
| - | |||
| - | if(Sec<=9) | ||
| - | { | ||
| - | lcd.print("0"); | ||
| - | lcd.print(Sec=now.second(),DEC); | ||
| - | } | ||
| - | else | ||
| - | lcd.print(Sec=now.second(),DEC); | ||
| - | lcd.setCursor(0,1); | ||
| - | lcd.print("Date: "); | ||
| - | lcd.print(now.day(),DEC); | ||
| - | lcd.print("/"); | ||
| - | lcd.print(now.month(),DEC); | ||
| - | lcd.print("/"); | ||
| - | lcd.print(now.year(),DEC); | ||
| - | TimeCheck(); | ||
| - | delay(200); | ||
| - | } | ||
| - | void current() | + | delay(600); |
| - | { | + | noTone(tonePin); |
| - | lcd.setCursor(0,1); | + | |
| - | lcd.print(Hor); | + | |
| - | lcd.print(":"); | + | |
| - | lcd.print(Min); | + | |
| - | lcd.print(":"); | + | |
| - | lcd.print(Sec); | + | |
| } | } | ||
| </code> | </code> | ||
| Line 300: | Line 136: | ||
| <note> | <note> | ||
| - | [[https://www.arduino.cc/reference/en/language/functions/communication/wire/|WIRE Library]] | + | [[https://sites.google.com/site/arduinoelectronicasiprogramare/arduino-si-senzori/1/senzor-de-parcare|Documentatie]] |
| - | [[https://docs.arduino.cc/learn/built-in-libraries/eeprom|EEPROM Library]] | + | |
| - | [[https://www.arduino.cc/reference/en/libraries/rtclib/|RTC Library]] | + | |
| - | [[https://www.arduino.cc/reference/en/libraries/liquidcrystal/|Liquid Crystal]] | + | |
| </note> | </note> | ||
| <html><a class="media mediafile mf_pdf" href="?do=export_pdf">Export to PDF</a></html> | <html><a class="media mediafile mf_pdf" href="?do=export_pdf">Export to PDF</a></html> | ||