Download presentation
Presentation is loading. Please wait.
Published byJocelin Miller Modified over 6 years ago
1
SArduino Training 2018 cho THPT Saigon Institute of Technology
IR Sensor Board SArduino Training 2018 cho THPT Saigon Institute of Technology Biên soạn: IT SaigonTech
2
IR Sensor ( module TCRT5000 )
Nguyên lý: Consists of an infrared transmitter and infrared receiver. When the IR signal is received from the transmitter, the receiver will operate. When there is infrared light from the transmitter, if there is an obstruction, the light will be reflected back to the receiver. Application: used in obstacle detection applications, line tracking, .... Datasheet:
3
How it works
4
16 IR sensor board Diamter: 24 cm
a. From below b. From above c. On Robot Diamter: 24 cm 16 IR arranged at equally-fixed angle: 22.5 degree
5
Wiring Sensor Board Arduino U0 – U15 A0 – A15
6
Wiring (cont) Sensor Board Arduino 0V GND 5V
7
Arrangement 90° Motor 1 U4 U5 U3 U6 U2 U7 U1 180° 0° U0 U8 Motor 3 U9
*Robot from above 270°
8
… Analog signal reading Pseudo code analogRead (sensorPin);
*Note: Pseudo code is not a complete code and need to be adjusted according to specific programming language that is in used Analog signal reading Pseudo code analogRead (sensorPin); The sensorVal value will change with the (continuous) range from If sensorVal> can be considered as the being on the black area, and vice versa sensorVal <511.5 can be considered white area. …
9
Sample code Pascal begin value:= analogRead(sensor_0);
{Read analog value from sensor U0} uses STArduino; const sensor_0 = A0; procedure setup; begin serialBegin(9600); pinMode(sensor_0,INPUT); end; procedure loop; var value: integer; begin value:= analogRead(sensor_0); serialPrintString('Value: '); serialPrintlnLong(value); delay(50); end; setup; loop; end.
10
Sample code Arduino IDC (C/C++)
/* Read analog value from sensor U0 */ #define sensor_0 A0 void setup(){ Serial.begin(9600); pinMode(sensor_0,INPUT); } void loop(){ int value; value = analogRead (sensor_0); Serial.print (“Value: “); Serial.print (value); Serial.print (“\n”); delay (50); }
11
*Note: Pseudo code is not a complete code and need to be adjusted according to specific programming language that is in used Hint: If reading from many Sensors should use “For”: Pseudo Code //Declare arrays int sensor[n] = {A0, A1, …, An}; int value[n]; //Using a for loop to get all the value for (int i = 0; i <= n; i++){ value[i] = analogRead(sensor[i]); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.