Differences

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

Link to this comparison view

pm:prj2024:vstoica:victor.ionescu0812 [2024/05/27 00:39]
victor.ionescu0812 [Descriere generală]
pm:prj2024:vstoica:victor.ionescu0812 [2024/05/30 08:41] (current)
victor.ionescu0812
Line 34: Line 34:
  
  
-<note tip> +<note tip>  
-Descrierea codului aplicaţiei ​(firmware): + 
-  * mediu de dezvoltare ​(if any) (e.gAVR Studio, CodeVisionAVR+Codul a fost scris in Arduino IDE. 
-  librării şi surse 3rd-party ​(e.gProcyon AVRlib+ 
-  ​* algoritmi şi structuri pe care plănuiţi să le implementaţi + 
-  ​(etapa 3surse şi funcţii implementate+ 
 +  while (1{ 
 +    ​if ​((PINC & (1 << PINC0)) == 0 && flag1 == 0) { 
 +      timer1 = TCNT1; 
 +      flag1 = 1; 
 +    } 
 + 
 +    ​if ((PINC & (1 << PINC1)) == 0 && flag2 == 0) { 
 +      timer2 = TCNT1; 
 +      flag2 = 1; 
 +    } 
 + 
 +    if (flag1 == 1 && flag2 == 1) { 
 +      if (timer1 > timer2) { 
 +        Time = (timer1 - timer2) / (F_CPU / 1024.0); 
 +      } else if (timer2 > timer1) { 
 +        Time = (timer2 - timer1) / (F_CPU / 1024.0); 
 +      } 
 +      speed = (distance / Time) 3600 / 1000; 
 +      flag1 = 0; 
 +      flag2 = 0; 
 +    } 
 + 
 +    if (speed == 0) { 
 +      lcd_set_cursor(0,​ 1); 
 +      if (flag1 == 0 && flag2 == 0) { 
 +        lcd_print("​No car detected "); 
 +      } else { 
 +        lcd_print("​Searching...    "​); 
 +      } 
 +    } else { 
 +      lcd_clear();​ 
 +      lcd_set_cursor(0,​ 0); 
 +      lcd_print("​Speed:"​);​ 
 +      char buffer[10];​ 
 +      dtostrf(speed,​ 4, 1, buffer); 
 +      lcd_print(buffer);​ 
 +      lcd_print("​ Km/Hr  "); 
 +      ​lcd_set_cursor(0,​ 1); 
 +      if (speed > 50) { 
 +        lcd_print(" ​ Over Speeding ​ "); 
 +        PORTB |= (1 << PORTB5)
 +      } else { 
 +        lcd_print(" ​ Normal Speed   "​);​ 
 +      } 
 +      _delay_ms(3000);​ 
 +      PORTB &= ~(1 << PORTB5); 
 +      speed = 0; 
 +      lcd_clear(); ​  
 +    } 
 +  } 
 +  ​
 </​note>​ </​note>​
  
-===== Rezultate Obţinute ​=====+===== Cod complet ​=====
  
 <note tip> <note tip>
-Care au fost rezultatele obţinute în urma realizării proiectului vostru.+ 
 +#include <Wire.h> 
 +#include <​LiquidCrystal_I2C.h>​ 
 + 
 +LiquidCrystal_I2C lcd(0x27, 16, 2); 
 + 
 +int timer1; 
 +int timer2; 
 + 
 +float Time; 
 + 
 +int flag1 = 0; 
 +int flag2 = 0; 
 + 
 +float distance = 3.5; 
 +float speed; 
 + 
 +int ir_s1 = A0; 
 +int ir_s2 = A1; 
 + 
 +int buzzer = 13; 
 + 
 +void setup() { 
 +  pinMode(ir_s1,​ INPUT); 
 +  pinMode(ir_s2,​ INPUT); 
 +  pinMode(buzzer,​ OUTPUT); 
 + 
 +  lcd.begin(16,​ 1); 
 +  lcd.init();​ 
 +  lcd.backlight();​ 
 +  lcd.clear();​ 
 +  lcd.setCursor(0,​ 0); 
 +  lcd.print("​VYCTOR MASHINA"​);​ 
 +  delay(2000);​ 
 +  lcd.clear();​ 
 +
 + 
 +void loop() { 
 +  if (digitalRead(ir_s1) == LOW && flag1 == 0) { 
 +    timer1 = millis(); 
 +    flag1 = 1; 
 +  } 
 + 
 +  if (digitalRead(ir_s2) == LOW && flag2 == 0) { 
 +    timer2 = millis(); 
 +    flag2 = 1; 
 +  } 
 + 
 +  if (flag1 == 1 && flag2 == 1) { 
 +    if (timer1 > timer2) { 
 +      Time = timer1 - timer2; 
 +    } else if (timer2 > timer1) { 
 +      Time = timer2 - timer1; 
 +    } 
 +    Time = Time / 1000;  
 +    speed = (distance / Time);  
 +    speed = speed * 3600;  
 +    speed = speed / 1000;  
 +  } 
 + 
 +  if (speed == 0) { 
 +    lcd.setCursor(0,​ 1); 
 +    if (flag1 == 0 && flag2 == 0) { 
 +      lcd.print("​No car  detected"​);​ 
 +    } else { 
 +      lcd.print("​Searching... ​   "); 
 +    } 
 +  } else { 
 +    lcd.clear();​ 
 +    lcd.setCursor(0,​ 0); 
 +    lcd.print("​Speed:"​);​ 
 +    lcd.print(speed,​ 1); 
 +    lcd.print("​Km/​Hr ​ "); 
 +    lcd.setCursor(0,​ 1); 
 +    if (speed > 50) { 
 +      lcd.print(" ​ Over Speeding ​ "); 
 +      digitalWrite(buzzer,​ HIGH); 
 +    } else { 
 +      lcd.print(" ​ Normal Speed   "​);​ 
 +    } 
 +    delay(3000);​ 
 +    digitalWrite(buzzer,​ LOW); 
 +    speed = 0; 
 +    flag1 = 0; 
 +    flag2 = 0; 
 +  } 
 +
 </​note>​ </​note>​
  
pm/prj2024/vstoica/victor.ionescu0812.1716759546.txt.gz · Last modified: 2024/05/27 00:39 by victor.ionescu0812
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