Index

37 Sensors Overview

Sensor.Engine MICRO

  1. Sensor.Engine MICRO Features
  2. Pinout and Pin use
  3. BASIC Overview
  4. SEM Library functions

37+ Sensors

  1. Analog Hall-effect
  2. Analog Joystick
  3. Analog Temperature
  4. Ball Switch
  5. Bi-color LED
  6. Button
  7. Character LCD
  8. Flame
  9. Hall-effect Switch
  10. HMI Display
  11. Humidity and Temperature
  12. IR Receiver
  13. IR Transmitter
  14. Keypad
  15. LASER
  16. Light Cup
  17. Liquid
  18. Mercury Switch
  19. Microphone
  20. Multicolor Flashing LED
  21. Obstacle Avoidance
  22. Photo Interruptor
  23. Photoresistor
  24. Piezo Driver or Annunciator
  25. Pulse
  26. Reed Switch
  27. Relays and Drivers
  28. RGB LED
  29. Rotary Encoder
  30. Servo
  31. Shock and Impulse
  32. Speaker
  33. Temperature 18B20
  34. Temperature Threshold
  35. Touch Sensor
  36. Tracking
  37. Ultrasonic Distance

USBmicro U4xx

  1. U401
  2. U421
  3. U451

CircuitGizmos

Projects

  1. Controlling MedeaWiz Sprite

RGB

LED



images\42-1.png
Image: RGB LED module, through-hole (150 ohm current limiting resistors)


images\42-2.png
Image: RGB LED module, surface mount 5050


Description



LED containing red, green, and blue emitters, each controlled independently. Some modules have current limiting resistors, some do not.

Also called: full color LED, three color LED, tri-chromatic LED, KY021, KY016.

Found in kits: 37 sensors, 45 sensors (through-hole LED).

Found in kits: 20 sensors, 37 sensors, 45 sensors (SMT LED).


Specification/Notes:



• LED: Either TH (5mm) or SMT 5050
• Current: under 20mA typical per LED
• Forward voltage drop red: 2.1V
• Forward voltage drop green: 3.2V
• Forward voltage drop blue: 3.2
• Red: 625nm
• Green: 530nm
• Blue: 465nm
• Size: 20mm X 15mm

Some modules have current limiting resistors, some do not. The typical resistance value is 120 – 330 Ohms. The three LED dice internal to the package are common cathode.

Pins are frequently labeled incorrectly. RGB, BGR, GRB, etc.

There are a number of different sources for these modules. Not every module that looks similar to the ones here behaves exactly the same. Check the specific module that you have for differences in function, voltage levels, pinout, and inactive/active states. Some modules have been found to have incorrectly labeled pins and even poorly soldered components.


Module Pin-out:


images\42-3.png
Image: Typical/common pinout. Always check the pinout for the module that you have.


Sensor.Engine:MICRO RGB module test



Blink the red, green, and blue elements of the RGB LED using the Sensor.Engine:MICRO.

RGB module test wiring



images\42-4.png
Image: Wiring the RGB LED to a SEM.

Black wire – Common ground, SEM GND - Module Ground

Red wire – RedLED element, SEM P4 - Module R

Green wire – RedLED element, SEM P5 - Module G

Blue wire – RedLED element, SEM P6 - Module B

This particular through-hole LED module has a current limiting resistor so no external resistor needed


SETPIN 4, DOUT
SETPIN 5, DOUT
SETPIN 6, DOUT

 
DO
  PAUSE 200 : PIN(4) = 1 : PAUSE 200 : PIN(4) = 0
  PAUSE 200 : PIN(5) = 1 : PAUSE 200 : PIN(5) = 0
  PAUSE 200 : PIN(6) = 1 : PAUSE 200 : PIN(6) = 0
LOOP

'Comment here

Code: RGB module test code in MMBasic


This test code sets pins 4, 5, and 6 to outputs and then sets each of those outputs high and low to turn the color element on and off.

RGB module test results


images\42-5.png
Image: Animated .gif

Animated .gif:
Linked file: 20190322_213036.gif




r = 1
g = 1
b = 100

PWM 11000, r, g, b
PAUSE 5000

DO
  for r = 0 to 99 STEP 2
    PWM 11000, r, g, b
    PAUSE 10
  NEXT r
  
  PAUSE 5000
  
  for b = 100 to 1 STEP -2
    PWM 11000, r, g, b
    PAUSE 10
  NEXT b

  PAUSE 5000
  
  for g = 0 to 99 STEP 2
    PWM 11000, r, g, b
    PAUSE 10
  NEXT g

  PAUSE 5000
  
  for r = 100 to 1 STEP -2
    PWM 11000, r, g, b
    PAUSE 10
  NEXT r

  PAUSE 5000
  
  for b = 0 to 99 STEP 2
    PWM 11000, r, g, b
    PAUSE 10
  NEXT b

  PAUSE 5000
  
  for g = 100 to 1 STEP -2
    PWM 11000, r, g, b
    PAUSE 10
  NEXT g

  PAUSE 5000
  
LOOP

Code: RGB module test code in MMBasic

This test code uses PWM to slowly increase/decrease the output of the R, G, and B channels in patterns. There are 5 second delays between the changes.

The PWM outputs can be run through a solid state relay (see relay page) or a FET to drive 5V or 12V RGB LED strips.

On Instructables: https://www.instructables.com/id/Using-RGB-LED-From-37-Sensors-Kit/



USBmicro U4xx RGB module test



Blink the red, green, and blue elements of the RGB LED using the USBmicro U4xx. The U401 connects to a computer using USB and can be controlled in several languages running on the computer.

images\42-6.png
Image: RGB module test wiring:

Black wire – Common ground, U4xx Ground

Red wire – RedLED element, U4xx A0 - Module R

Green wire – RedLED element, U4xx A1 - Module G

Blue wire – RedLED element, U4xx A2 - Module B



#INCLUDE ONCE "USBmDLL.inc"

Dim workstr As String * 255
Dim result As Integer

DIm PortAval as byte

'------------------------------------------------------------------------------
'thinAir Visual Designer
'------------------------------------------------------------------------------

'---Needed thinBasic modules
USES "UI"

'---Controls IDs---
Begin ControlID
%IDC_CHECKBOX_RED
%IDC_CHECKBOX_GREEN
%IDC_CHECKBOX_BLUE
%IDC_EDIT_2
End ControlID

' Public this
DIM hDlg     As Long


'------------------------------------------------------------------------------
' Main thinBasic function
'------------------------------------------------------------------------------
Function TBMain() As Long
MainWindow_Create(%HWND_DESKTOP)
End Function


'------------------------------------------------------------------------------
' Create main Window
'------------------------------------------------------------------------------
Function MainWindow_Create(ByVal hParent As Long) As Long

'Local hDlg     As Long
Local hFont    As Long
Local lStyle   As Long
Local lStyleEx As Long
lStyle = _                          
        %WS_DLGFRAME          | _   
        %WS_CAPTION           | _   
        %WS_SYSMENU           | _   
        %WS_OVERLAPPEDWINDOW  | _   
        %WS_CLIPCHILDREN      | _   
        %WS_CLIPSIBLINGS      | _   
        %DS_CENTER                  
lStyleEx = 0                        

Dialog New Pixels, hParent, "RGB1", -1, -1463240, lStyle, lStyleEx, TO hDlg

hFont = Font_Create("MS Sans Serif"8)
Dialog Send hDlg, %WM_SETFONT, hFont, 0

CONTROL ADD CHECKBOX, hDlg, %IDC_CHECKBOX_RED, "Red"81605624, %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR %WS_VISIBLE OR %BS_AUTOCHECKBOX, 0
CONTROL ADD CHECKBOX, hDlg, %IDC_CHECKBOX_GREEN, "Green"81845624, %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR %WS_VISIBLE OR %BS_AUTOCHECKBOX, 0
CONTROL ADD CHECKBOX, hDlg, %IDC_CHECKBOX_BLUE, "Blue"82085624, %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR %WS_VISIBLE OR %BS_AUTOCHECKBOX, 0
CONTROL ADD TEXTBOX, hDlg, %IDC_EDIT_2""88448144, %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR %WS_VISIBLE or %ES_MULTILINE, %WS_EX_CLIENTEDGE or %ES_MULTILINE

  ' Display DLL info
  workstr = ""
  USBm_About(workstr)
  CONTROL APPEND TEXT hDlg, %IDC_EDIT_2"DLL Info: " + workstr
  CONTROL APPEND TEXT hDlg, %IDC_EDIT_2, CRlf 
  workstr = ""
  USBm_Version(workstr)
  CONTROL APPEND TEXT hDlg, %IDC_EDIT_2"DLL Ver: " + workstr
  CONTROL APPEND TEXT hDlg, %IDC_EDIT_2, CRlf 
  workstr = ""
  USBm_Copyright(workstr)
  CONTROL APPEND TEXT hDlg, %IDC_EDIT_2"DLL Copyright: " + workstr
  CONTROL APPEND TEXT hDlg, %IDC_EDIT_2, CRlf 

  USBm_FindDevices()
  result = USBm_NumberOfDevices()
  CONTROL APPEND TEXT hDlg, %IDC_EDIT_2"Number of devices: " + STR$(result)
  CONTROL APPEND TEXT hDlg, %IDC_EDIT_2, CRlf 

  USBm_DirectionAOut(0)
  PortAval = 0
  USBm_WriteA(0,PortAval)

Dialog Show Modal hDlg, CALL MainWindow_Proc

Win_DeleteObject hFont

End Function

'------------------------------------------------------------------------------
' Main WIndow CallBack handler
'------------------------------------------------------------------------------
CallBack Function MainWindow_Proc() As Long

LOCAL pNMHDR   AS NMHDR PTR

LOCAL PageNo   AS LONG     

LOCAL hFontTab AS LONG    
  Local RedState as long
  Local GreenState as long
  Local BlueState as long

SELECT CASE (CBMSG)

    CASE %WM_INITDIALOG
    CASE %WM_COMMAND
        SELECT CASE LOWRD(CBWPARAM)
            CASE %IDOK
            CASE %IDCANCEL
        END SELECT

    CASE %WM_NOTIFY
        CONTROL GET CHECK hDlg, %IDC_CHECKBOX_RED TO RedState
        CONTROL GET CHECK hDlg, %IDC_CHECKBOX_GREEN TO GreenState
        CONTROL GET CHECK hDlg, %IDC_CHECKBOX_BLUE TO BlueState
        
        If RedState = 1 then
          PortAval = BIT_Set(PortAval, 0)
        else
          PortAval = BIT_reSet(PortAval, 0)
        endif
        
        If GreenState = 1 then
          PortAval = BIT_Set(PortAval, 1)
        else
          PortAval = BIT_reSet(PortAval, 1)
        endif
        
        If BlueState = 1 then
          PortAval = BIT_Set(PortAval, 2)
        else
          PortAval = BIT_reSet(PortAval, 2)
        endif
        
        USBm_WriteA(0,PortAval)

    CASE %WM_DESTROY
End Select
End Function







Code: RGB module test code in thinBasic


This test code sets port A to output, then sets pins A0 (red), A1 (green), and A2 (blue) high or low to turn the color element on and off.


images\42-7.png
Image: RGB1.tBasic screen


All content, not otherwise posted with a copyright notice, is Copyright 2017+ to the owner of 37sensors.com.