Interface Actuators to Arduino Board Using PictoBlox: Scratch Blocks Based Coding Software

by theSTEMpedia in Circuits > Arduino

3599 Views, 3 Favorites, 0 Comments

Interface Actuators to Arduino Board Using PictoBlox: Scratch Blocks Based Coding Software

Instructables-PictoBlox-Video-Tutorials_Ep-03.png
Interface-Servo-to-Arduino.gif
Control-Servo-Using-IR-Sensor.gif

In this tutorial, we are going to see how to interface the servo motor to Arduino Uno and control it using an IR sensor using PictoBlox, our graphical programming software. A servo motor, or simply, a servo, is a rotary actuator that rotates or push parts of a machine to which it is connected, with precision. They rotate in a particular angle and then stop.

You can download PictoBlox from here.

Let’s begin

Hardware Components Required

  • Arduino Uno (Note: You can use any other Arduino Board of your choice or ESP32)
  • Micro Servo Motor with Accessories
  • IR Sensor
  • USB A-B Cable
  • Male-to-Male Jumper Cable
  • Male-to-Female Jumper Cable

What Is an Actuator?

Control-Motors.gif

An actuator is a device that actuates something. In simple words, it produces motion. It helps other devices move and interact with their surrounding environment. The actuator takes in energy and uses it to help the device move. Servo motors and DC motors are types of electric actuators.

Connecting the Servo Motor and IR Sensor to UNO

IR Connection to Uno.png

Let's begin by connecting our Servo Motor and IR Sensor to Arduino Uno.

Note: You can use any board of your choice, all you need to do is change the hat block.

First, connect the servo to Uno.

  • Connect the servo’s brown wire to Uno’s GND pin
  • Connect the red wire to Uno’s VIN pin
  • Connect the orange wire to Uno’s PWM pin 5

Now, let’s connect the IR sensor to Uno.

  • Connect the sensor’s VCC pin to Uno’s 5V pin.
  • Connect the sensor’s GND pin to Uno’s GND pin.
  • Connect the sensor’s OUT pin to Uno’s Digital pin 2.

Interfacing Arduino Uno to PictoBlox

To Interface Arduino to PictoBlox:

  • First, open PictoBlox.
  • Then, connect Uno to your computer via a USB cable.
  • Next, click on the Board button in the toolbar and select Arduino Uno from the drop-down menu.
  • Then, click on the Connect button and select the appropriate port.

Controlling Servo Using IR Sensor

We are going to make servo turn 45° if the IR sensor detects an object, otherwise, it should remain at 0°.

Let's write the script in PictoBlox for the same:

To check whether the IR Sensor has detected an object or not, we'll use the read digital sensor block.

Use an if-else and drag and drop it into the hexagonal space of the if-arm.

Now, we need to make the servo turn 45° if the if condition is true. Thus, use the set servo block from the Actuators palette.

Write 45 in the white space given and place it in below the if arm.

Now, the servo shouldn't turn if any object is not detected. use the set servo block and write 0 in the white space.

Finally, add a forever block along with the hat block of when Arduino Uno starts up above the entire script.

Switch to Upload mode by toggling this button. Click on the Upload Code button to upload the code

Final Output

Interface-Servo-to-Arduino.gif

Try bringing the hand close to the IR sensor the servo rotates to 45° and when you take your hand away it turns back to 0°.

Taking the Activity a One Step Closer

Control-Servo-Using-IR-Sensor.gif

We have made a miniature house whose door opens automatically as soon as the IR sensor detects an object. And closes as soon as the IR sensor stops detecting the object. We will use the servo to open and close the door. Try making the same for you.

Explore: Try interfacing the DC motor to Uno and control it using the Sensor.