HS-S06B Four-way Photosensitive Sensor

HS-S06B Four-way Photosensitive Sensor

1. Introduction


2. Schematic

4-bit photoelectric sensor HS-S06B schematicClick to view

Module Parameters

Pin Name

description

GND

GND (Negative Power Input)

VCC

VCC (Positive Power Input)

A1|S

Digital Signal Pin

A2|S

Digital Signal Pin

A3|S

Digital Signal Pin

A4|S

Digital Signal Pin

  • Power Supply Voltage: 3.3V / 5V

  • Connection Type: 2.54mm Header

  • Installation Method: Double Screw Fixed

4, Circuit Board Size

5 of Arduino IDE example program

Attention: If prompted with an error message about the library file during program upload, please import the library file first!
Arduino IDE Library Download and Import Tutorial:
Click to view

Example program (UNO development board):

volatile int zoushang;
volatile int youshang;
volatile int zouxia;
volatile int youxia;

void setup(){
  Serial.begin(9600);
  zoushang = 0;
  youshang = 0;
  zouxia = 0;
  youxia = 0;
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);
  pinMode(A3, INPUT);
  pinMode(A4, INPUT);
}

void loop(){
  zouxia = analogRead(A1);
  zoushang = analogRead(A2);
  youxia = analogRead(A3);
  youshang = analogRead(A4);
  delay(500);
  Serial.print("A1๏ผš");
  Serial.print(zouxia);
  Serial.print("******");
  Serial.print("A2๏ผš");
  Serial.print(zoushang);
  Serial.print("******");
  Serial.print("A3๏ผš");
  Serial.print(youxia);
  Serial.print("******");
  Serial.print("A4๏ผš");
  Serial.println(youshang);

}โ€‹

6, ESP32 Python Example (for Mixly IDE/Misashi)

Choose the development board Python ESP32 [ESP32 Generic(4MB)] and upload in code mode

Attention: If prompted with an error message about the library file during program upload, please import the library file first!
Download and import tutorial for Mixly IDE ESP32 library:
Click to view

Example program (ESP32-Python):

import machine
import time


adc34 = machine.ADC(machine.Pin(34))
adc35 = machine.ADC(machine.Pin(35))
adc36 = machine.ADC(machine.Pin(36))
adc39 = machine.ADC(machine.Pin(39))
while True:
    print(' A1: ',end ="")
    print(adc34.read_u16(),end ="")
    print(' A2: ',end ="")
    print(adc35.read_u16(),end ="")
    print(' A3: ',end ="")
    print(adc36.read_u16(),end ="")
    print(' A4: ',end ="")
    print(adc39.read_u16())
    time.sleep_ms(200)

7, Mixly example program (graphical language)

Example program (UNO development board):Click to download
Attention: If prompted with an error message about the library file during program upload, please import the library file first!
Download and import tutorial of Mixly IDE Arduino library:Click to view

Example Program (ESP32 Development Board):Click to download
Attention: If prompted with an error message about the library file during program upload, please import the library file first!
Download and import tutorial for Mixly IDE ESP32 library:
Click to view

8. Setting up the Test Environment

Arduino UNO Test Environment Setup

Prepare Components:

  • HELLO STEM UNO R3 PRO DEVELOPMENT BOARD *1

  • USB TYPE-C DATA CABLE *1

  • Four-channel photoelectric sensor module (HS-S06B) *1

  • 1P female to female Dupont wire *6 pieces or 3P female to female Dupont wire *2 pieces

Circuit wiring diagram:

ESP32 Test Environment Setup

Prepare Components:Pending update...

Circuit wiring diagram:Pending update...

9, Video tutorialย ย 

Video tutorial:Click to view

10, Test results

Arduino UNO test results: