Login

Interface IR sensor and RGB LED with NodeMCU

Objectives

  • Interface IR distance sensor and RGB LED with NodeMCU
  • Use distance values from IR sensor and control color of RGB LED

Things

  1. NodeMCU board (quantity: 1 no.)
  2. Micro USB cable A to B (quantity: 1 no.)
  3. Breadboard (quantity: 1 no.)
  4. IR sensor module (quantity: 1 no.)
  5. Common Cathode RGB LED module (quantity: 1 no.)
  6. Jumper wire – male to male (quantity: 8 no.)
  7. Arduino IDE on your computer

Let’s begin!

Since we can get a measure of the distance of the obstacle from the analog value of the IR sensor, we can use these values to make the RGB LED give a certain color for a particular range of distance.

Let’s make the RGB LED green when the obstacle is far, and red when the obstacle comes closer.

Interfacing IR sensor module and Common Cathode (-) RGB LED module with NodeMCU

 

Interfacing IR sensor module and Common Cathode (-) RGB LED module with NodeMCU

 

Final Code

To copy the code, right click on view raw at the bottom of the code, click on open link in new tab and then copy the code.

There you go!

Takeaway

Loader Loading...
EAD Logo Taking too long?
Reload Reload document
| Open Open in new tab
April 22, 2020

0 responses on "Interface IR sensor and RGB LED with NodeMCU"

Leave a Message

Your email address will not be published.

top

Knowledge and Content by Li2 Technologies | © 2021 NASSCOM Foundation | All rights reserved

X