Difference between revisions of "Crowbits-Adjustable Infrared Sensor"

From Elecrow
Jump to navigation Jump to search
Line 21: Line 21:
 
2.Connect the module to the D2 interface of the Crowbits-UNO board, as shown in the figure:
 
2.Connect the module to the D2 interface of the Crowbits-UNO board, as shown in the figure:
  
 
+
[[File: Crowbits-Adjustable Infrared Sensor-Wiki 1.jpg |600px]]
  
 
3.Upload the following code to the Crowbits-UNO board.
 
3.Upload the following code to the Crowbits-UNO board.
Line 43: Line 43:
  
 
4.After the upload is successful, open the serial port monitor, the baud rate is set to 9600. When an object is detected, the serial port will print “object detected.”
 
4.After the upload is successful, open the serial port monitor, the baud rate is set to 9600. When an object is detected, the serial port will print “object detected.”
 +
 +
[[File: Crowbits-Adjustable Infrared Sensor-Wiki 2.jpg |600px]]

Revision as of 15:17, 29 July 2020

Description

This infrared distance switch features a high-sensitivity photo reflector to perform distance detection function, ranging from 3cm to 80cm. When the infrared light emitted by the emitter gets reflected on a surface that blocked it, the phototransistor can pick up the signal for distance calculation. Also a potentiometer for adjustment is arranged for easy and clear use. It is small, easy to use/assemble, and inexpensive. Useful for robotics, interactive media, industrial assembly line, etc.

Crowbits-2G-Module-1.jpg

Features

  • Easy to use/assemble
  • High-sensitivity

Specification

  • Power supply: 3.3V
  • Current: 100mA
  • Range: 3-80cm adjustable
  • Wire length: 20cm

Usage

The following sketch demonstrates a simple application of the module.

1.You need to prepare a Crowbits motherboard, such as Crowbits-UNO board.

2.Connect the module to the D2 interface of the Crowbits-UNO board, as shown in the figure:

Crowbits-Adjustable Infrared Sensor-Wiki 1.jpg

3.Upload the following code to the Crowbits-UNO board.

void setup()  {
 Serial.begin(9600);
 pinMode(2,INPUT);
}
void loop()  {
 while(1)  {
   delay(500);
   if(digitalRead(2)==LOW)  {
     Serial.println("object detected.");
   }
   else  {
     Serial.println("no object detected.");
   }
 }
}

4.After the upload is successful, open the serial port monitor, the baud rate is set to 9600. When an object is detected, the serial port will print “object detected.”

Crowbits-Adjustable Infrared Sensor-Wiki 2.jpg