How to Interface IR Sensor with evive in PictoBlox

About This Tutorial
This tutorial discusses what are IR sensors, how to calibrate them, and how to interface them with evive in PictoBlox with the help of a sample program in Stage mode.
Tutorial Info

Introduction

An infrared (IR) sensor a proximity sensor, or a ‘nearness’ sensor that senses whether there is an object near it or not. If it detects an object, the sensor will turn ON; if not, it will remain OFF.

An IR sensor has two small LED indicators – one for power, which is ON the entire time the sensor is ON; the other is the Signal LED which detects the object. The signal LED has two states or situations:

  • ON (Active) when it detects an object
  • OFF (Inactive) when it doesn’t detect any object

How to Calibrate an IR Sensor

Calibrating the sensor is essentially is making sure that the LED turns ON when it detects the object and turns OFF when it doesn’t. That’s it.

Follow the steps below to calibrate the sensor:

  1. Place an object at least 15cm away from the robot. If the signal LED is OFF, the sensor is working properly. Otherwise, gently turn the potentiometer (that tiny blue cube with a screw in it) with a screwdriver in the anti-clockwise direction such that the LED turns OFF.
  2. Similarly, place an object about 5cm from the sensor. If the signal LED is ON, then it is working properly. Otherwise, turn the potentiometer in the clockwise direction such that the LED turns ON.
  3. Repeat the above two steps till the signal LED works as is should in both cases.

How to Interface the IR Sensor

Activity: Detecting Black and White

Wiring

Follow the steps below to connect the IR sensor to evive:

  1. Take a red male-to-female jumper wire; connect the female end of the wire to the VCC pin of the IR sensor. Take the male end and connect it to the 5V pin in the top-left corner of evive.
  2. Next, take a black male-to-female jumper wire and connect its female end to the GND pin of the IR sensor; take the male end and connect it to the GND pin in the top-left corner evive, below the 5V pin.
  3. Take an orange male-to-female jumper wire and connect its female end to the OUT pin of the sensor; take the male end and connect to digital pin 2, present below the breadboard under the magic lid.

Script

evive Notes Icon
When working with evive on PictoBlox for the very first time, or if you’ve previously uploaded another code to evive, you must upload the firmware in order to upload new code to it. You can find the procedure for the same HERE.

Follow the steps below to write the script:

  1. Connect evive to your computer and open PictoBlox; if already open and working on a project, save that project. Then, click on New.
  2. Go to the toolbar and click on the Board menu. Then select evive as your board. Pictoblox Board Selection
  3. Next, click on the Connect menu and from the fly-out menu, select the Port to which evive is connected e.g. COMXX or ttyXX.Once you select the port, the icon beside the Connect tab will become connected.Connect-Disconnect Icon
  4. Go to the Events palette and drag and drop the when flag clicked block.
  5. Go to the Display palette and drag and drop the fill screen with () color block below the when flag clicked block. You can change the background color if you want to by clicking on the color and moving the sliders in the drop-down menu.Change background color_1
  6. From the same palette, drag and drop the set text color to () with () background & size to () block below the fill screen with () color block.
  7. From the Control palette, drag and drop the forever block below the set text color to () with () background & size to () block.
  8. From the Display palette, drag and drop the set cursor at () , () block.
  9. Go to the Control palette and drag and drop the if-else block below the set cursor at () , () block.
  10. Go to the evive palette and drag and drop the read state of digital pin () block inside the diamond-shaped space of the if-else block; set the pin number as 2.set digital pin_1
  11. Go to the Display palette and drag and drop the write () block below the if arm of the if-else block.  Replace the text with WHITE.write block_1
  12. Drag and drop another write () block below the else arm of the if-else block and replace the text with BLACK.

Below is the complete script:

Interfacing IR sensor with evive in PictoBlox_2

Click on the green flag to run the script.

Click on the red octagon, next to the green flag to stop the script.

Conclusion

It this tutorial, you learned how to interface an IR sensor with evive using PictoBlox.

Hope you had fun! 🙂

Share this Tutorial
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Related Projects & Tutorials
How to use evive’s Slide Switch
This tutorial discusses different types of switches based on their pole and throw, what are slide switches, and a simple Arduino IDE sketch to display the state of evive's slide switch on the TFT screen.
All articles loaded
No more articles to load
Featured Projects
Space-Battle-Game on Scratch
Space Battle

This project will show you how to make a cool space battle game on your own in PictoBlox (Scratch-based programming) and play using your Smartphone!

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart