SlideShare a Scribd company logo
1 of 27
1)Ultrasonic Sensor
2)Parking sensor
3)Infrared reciever/transmiter
4)Infrared controller
Ultrasonic sensor
 Mates distance nga Parallax.
 Kthen valen ultrasound(ultratinguj) ne sinjale
elektrike edhe vice versa.
 Mate nga distanca 2cm  3m.
Ku perdoret?
 Meteorologji.
 Sisteme alarmi.
 Mjekesi.
 Industri.
 Automobilistik.
Si funksionon?
 Punon duke derguar nje ultra tingull edhe qendron ne pritje per te
degjuar kete tingull pasi perplaset me objektin edhe kthehet mbas tek
sensori.
 Kohezgjatja e pulsit eshte e barabarte me kohen qe I eshte dasht
ultratingullit qe te udhetoj nga sensori tek objekti edhe prap mbas tek
sensori.
 Duke perdorut shpejtesin e zerit,
ky uultratingull mund
te konvertohet ne distance.
Eksperimenti #1
 Cfare do te na duhet?
 Platforma Arduino.
 Ultrasonic sensor.
 Kabulla.
 Breadboard.
Qarku elektronik!
Edhe nje cik programim!
 /* Qarku:
 * VCC e sensorit eshte lidhur tek +5V
 * GND e sensorit eshte lidhur tek ground
 * TRIG e sensorit eshte lidhur tek dalja dixhitale 2
 * ECHO e sensorit eshte lidhur te dalja dixhitale 4
 const int trigPin = 8;
 const int echoPin = 7;
 void setup() {
 // Vendosim nje komunikim serial:
 Serial.begin(9600);}
Cik me shume programim!
 void loop(){
 // Do deklarojme variablat per te matur distancen,
 // rezultatet e distance do te jen ne kohezgjatje, inches, centimetra: long
duration, inches, cm;
 // Trigeri I sensorit do te vendoset High qe ait e gjeneroj nje ultratingull.
 // I japim si fillim nje pulse te shkurter LOW qe te zigurohemi qe trigeri te
nxier High:
 pinMode(trigPin, OUTPUT);
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);
Ja edhe pak!
 // Lexo sinjalin nga sensori
 pinMode(echoPin, INPUT);
 duration = pulseIn(echoPin, HIGH);
 // konvertojme kohen ne distance
 inches = microsecondsToInches(duration);
 cm = microsecondsToCentimeters(duration);
 Serial.print(inches);
 Serial.print("in, ");
 Serial.print(cm);
 Serial.print("cm");
 Serial.println();
 delay(100);
 }
Mbaruam!!!!!
 long microsecondsToInches(long microseconds){
 // Sipas datasheet te Paralax na duhen 73,746 miktosekonta per
 return microseconds / 74 / 2;
 }
 long microsecondsToCentimeters(long microseconds){
 // Shpejtesia e zerit eshte 340m/s ose 29 mikrosekonta per
 return microseconds / 29 / 2;
 }
Arduino Parking Sensor!
Perseri do programojme

Poooor fatemiresisht,
mendojme ne per ju 
Sansoret e drites
 IR Sensor  Photoresistor
IR Sensor
 Sensoret IR jane mikrocipe te vegjel!
 Kan nje qelize qe eshte e ndjeshme ndaj drites Infra te
kuqe!
 Ndodhen ne nje pjes te madhe te paisjeve
elektroshtepiake si psh:
 TV, DVD, Stereo etj.
Photo resistors
 Photo resistor ose ndryshe e njofur si resistenca te
varura nga drita(Light Dependent Resistor”LDR”)
 Jane resistenca te ndryshueshme ne varesi se sa drite u
ekspozohet
IR Sensor vs Photo resistor
 Detektojne ngjyrat
edhe driten e
dukshme nga syri I
njeriut.
 Mund te detektojne te
tera frekuencat.
 Sillen si resistenca.
 Jane te filtruar
apostafat per te mare
driten infra te kuqe.
 Kane demodulator qe
kerkon driten IR ne
moduluar ne
frekuencen 38kHz.
 Jane dixhital, nxierin 0
ose 1.
Eksperimenti #3
Qarku
Si thoni per pak programim?
 //Si fillim do deklarojm se ku do lidhet sensori me
Arduinon..
 // Kjo do na e bej me t thjesht qe te ndjekim kodin me
poshte.
 int sensorPin = A0;
 int ledPin = 9;
 // Gjithashtu do vendosim disa variable globale per
nivelin e drites.
 int max = 100;
 void setup() {
 // Do deklarojme pin-in e Led-it edhe LDR qe te jet
OUTPUT.
 pinMode(LED, OUTPUT);
 pinMode(LDR, OUTPUT);
 base = analogRead(LDR);
 Serial.begin(9600);
 }
 void loop() {
 Int v = analogRead(LDR);
 Serial.prinln(v);
 If ( v > threshold){
 digitalWrite(LED, LOW);}
 else{
 digitalWrite(LED, HIGH);
 }}
IR Sensor
Pasi mbaruam qarkun!
 Do hedhim librarin qe kemi shkarkuar nga
https://github.com/shirriff/Arduino-IRremote
tek Arduino->Libraries
 Duhet te sigurohemi qe emri I folderit qe kemi shkarkuar te mos ket “ -
, . ! “ te jet vetem shkronja
 Do shkojme tek File->Examples->Irremote
->IRrecvDemo
 Pasi ngarkuam kodin ne arduino do hapim Serial Monitor qe te
shikojme se ca vlerash na vijne nga pulti.
 Vlerat vijn ne form hexadecimale.
 Do shtypim butonat qe na
interesojne edhe do shenojme
kodin e tyre !
Edhe nje eksperiment te fundit!
 #include <IRremote.h>
 int before;
 int out=9; //connect your LED to pin 9
 int RECV_PIN = 11; //data out of IR receiver connects to pin 11
 IRrecv irrecv(RECV_PIN);
 decode_results results;
 void setup(){
 irrecv.enableIRIn(); // start the receiver
 before=0; //LED is turned off
 bright=255; //brightness value is at maximum (255)
 pinMode(out,OUTPUT);
 }
 void loop() {
 if (irrecv.decode(&results)) {
 if (results.value==0x20DF8D72){ //Code to turn the LED ON/OFF
 if(before==0){ // if the LED was turned off, then we turn it on
 digitalWrite(out,HIGH);
 before=1; //LED is now turned on
 }
 else{
 digitalWrite(out,LOW); //if the LED was turned on, then we turn it off
 before=0;
 }}

 irrecv.resume();
 }}

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Workshop #4

  • 1. 1)Ultrasonic Sensor 2)Parking sensor 3)Infrared reciever/transmiter 4)Infrared controller
  • 2. Ultrasonic sensor  Mates distance nga Parallax.  Kthen valen ultrasound(ultratinguj) ne sinjale elektrike edhe vice versa.  Mate nga distanca 2cm  3m.
  • 3. Ku perdoret?  Meteorologji.  Sisteme alarmi.  Mjekesi.  Industri.  Automobilistik.
  • 4. Si funksionon?  Punon duke derguar nje ultra tingull edhe qendron ne pritje per te degjuar kete tingull pasi perplaset me objektin edhe kthehet mbas tek sensori.  Kohezgjatja e pulsit eshte e barabarte me kohen qe I eshte dasht ultratingullit qe te udhetoj nga sensori tek objekti edhe prap mbas tek sensori.  Duke perdorut shpejtesin e zerit, ky uultratingull mund te konvertohet ne distance.
  • 5. Eksperimenti #1  Cfare do te na duhet?  Platforma Arduino.  Ultrasonic sensor.  Kabulla.  Breadboard.
  • 7. Edhe nje cik programim!  /* Qarku:  * VCC e sensorit eshte lidhur tek +5V  * GND e sensorit eshte lidhur tek ground  * TRIG e sensorit eshte lidhur tek dalja dixhitale 2  * ECHO e sensorit eshte lidhur te dalja dixhitale 4  const int trigPin = 8;  const int echoPin = 7;  void setup() {  // Vendosim nje komunikim serial:  Serial.begin(9600);}
  • 8. Cik me shume programim!  void loop(){  // Do deklarojme variablat per te matur distancen,  // rezultatet e distance do te jen ne kohezgjatje, inches, centimetra: long duration, inches, cm;  // Trigeri I sensorit do te vendoset High qe ait e gjeneroj nje ultratingull.  // I japim si fillim nje pulse te shkurter LOW qe te zigurohemi qe trigeri te nxier High:  pinMode(trigPin, OUTPUT);  digitalWrite(trigPin, LOW);  delayMicroseconds(2);  digitalWrite(trigPin, HIGH);  delayMicroseconds(10);  digitalWrite(trigPin, LOW);
  • 9. Ja edhe pak!  // Lexo sinjalin nga sensori  pinMode(echoPin, INPUT);  duration = pulseIn(echoPin, HIGH);  // konvertojme kohen ne distance  inches = microsecondsToInches(duration);  cm = microsecondsToCentimeters(duration);  Serial.print(inches);  Serial.print("in, ");  Serial.print(cm);  Serial.print("cm");  Serial.println();  delay(100);  }
  • 10. Mbaruam!!!!!  long microsecondsToInches(long microseconds){  // Sipas datasheet te Paralax na duhen 73,746 miktosekonta per  return microseconds / 74 / 2;  }  long microsecondsToCentimeters(long microseconds){  // Shpejtesia e zerit eshte 340m/s ose 29 mikrosekonta per  return microseconds / 29 / 2;  }
  • 14.
  • 15. Sansoret e drites  IR Sensor  Photoresistor
  • 16. IR Sensor  Sensoret IR jane mikrocipe te vegjel!  Kan nje qelize qe eshte e ndjeshme ndaj drites Infra te kuqe!  Ndodhen ne nje pjes te madhe te paisjeve elektroshtepiake si psh:  TV, DVD, Stereo etj.
  • 17. Photo resistors  Photo resistor ose ndryshe e njofur si resistenca te varura nga drita(Light Dependent Resistor”LDR”)  Jane resistenca te ndryshueshme ne varesi se sa drite u ekspozohet
  • 18. IR Sensor vs Photo resistor  Detektojne ngjyrat edhe driten e dukshme nga syri I njeriut.  Mund te detektojne te tera frekuencat.  Sillen si resistenca.  Jane te filtruar apostafat per te mare driten infra te kuqe.  Kane demodulator qe kerkon driten IR ne moduluar ne frekuencen 38kHz.  Jane dixhital, nxierin 0 ose 1.
  • 20. Si thoni per pak programim?  //Si fillim do deklarojm se ku do lidhet sensori me Arduinon..  // Kjo do na e bej me t thjesht qe te ndjekim kodin me poshte.  int sensorPin = A0;  int ledPin = 9;  // Gjithashtu do vendosim disa variable globale per nivelin e drites.  int max = 100;
  • 21.  void setup() {  // Do deklarojme pin-in e Led-it edhe LDR qe te jet OUTPUT.  pinMode(LED, OUTPUT);  pinMode(LDR, OUTPUT);  base = analogRead(LDR);  Serial.begin(9600);  }
  • 22.  void loop() {  Int v = analogRead(LDR);  Serial.prinln(v);  If ( v > threshold){  digitalWrite(LED, LOW);}  else{  digitalWrite(LED, HIGH);  }}
  • 24. Pasi mbaruam qarkun!  Do hedhim librarin qe kemi shkarkuar nga https://github.com/shirriff/Arduino-IRremote tek Arduino->Libraries  Duhet te sigurohemi qe emri I folderit qe kemi shkarkuar te mos ket “ - , . ! “ te jet vetem shkronja  Do shkojme tek File->Examples->Irremote ->IRrecvDemo  Pasi ngarkuam kodin ne arduino do hapim Serial Monitor qe te shikojme se ca vlerash na vijne nga pulti.  Vlerat vijn ne form hexadecimale.  Do shtypim butonat qe na interesojne edhe do shenojme kodin e tyre !
  • 25. Edhe nje eksperiment te fundit!
  • 26.  #include <IRremote.h>  int before;  int out=9; //connect your LED to pin 9  int RECV_PIN = 11; //data out of IR receiver connects to pin 11  IRrecv irrecv(RECV_PIN);  decode_results results;  void setup(){  irrecv.enableIRIn(); // start the receiver  before=0; //LED is turned off  bright=255; //brightness value is at maximum (255)  pinMode(out,OUTPUT);  }
  • 27.  void loop() {  if (irrecv.decode(&results)) {  if (results.value==0x20DF8D72){ //Code to turn the LED ON/OFF  if(before==0){ // if the LED was turned off, then we turn it on  digitalWrite(out,HIGH);  before=1; //LED is now turned on  }  else{  digitalWrite(out,LOW); //if the LED was turned on, then we turn it off  before=0;  }}   irrecv.resume();  }}