logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Raspberry Pi

Sensor Input Experiment Using Raspberry Pi

DevicePlus Editorial Team
Published by DevicePlus Editorial Team at January 21, 2020
Categories
  • Raspberry Pi
Tags

This article was translated to English, and was originally published for deviceplus.jp.

This series will focus on learning the principles and basics of crafting electronic kits through simple crafts made with Raspberry Pi. Teaching us today will be Mrs. Naomi Ito, author of a series of books explaining about “deep mechanisms” in the media art field. In this article we’ll be diving into sensor input experiments.

[Table of Contents]

1. Introduction
2. Mechanism for Turning the Motor
3. About the Sensor
4. Connect the Phototransistor to the GPIO
5. Connect the Phototransistor to the GPIO
6. Conclusion

1. Introduction

The world nowadays is changing at a rapid pace every day and there are many people out there who can’t keep up — not necessarily because they don’t have an interest in new things, but rather, it’s tiring enough trying to catch up with everything that is new. That’s why today I’m thinking about working on a variety of different things, focusing on what I think is interesting while organizing my thoughts and what needs to be done.

2. Mechanism for Turning the Motor

Last time I used a DC motor. I’ve had plenty of great experience working with model cars, plastic models and radio-controlled models. When I think about it, a DC motor is kind of like a representative for energy conversion, which converts electrical energy into kinetic energy. A simple diagram of the mechanism looks like this inside.

Mechanism for Turning the Motor

Of course, the basic principle is that the magnetic field generated by the flow of electricity affects the magnetic field of the permanent magnet (ferrite magnets), and creates a physical force = kinetic energy. If you’re wondering what that mechanism is, it is, of course, Fleming’s left-hand rule. Perhaps you’ve heard of it before?

About Fleming’s Left-Hand Rule
First, you should know that Fleming’s Law has a right and left hand. The thumb, forefinger and middle finger are shaped perpendicular to the three-dimensional XYZ axis. The thumb is in the direction of the force, the index finger is in the direction of the magnetic field and the middle finger is in the direction of where the electricity is flowing.

Fleming’s Law left-hand rule

If you look at your right and left hands in front of you, you can see that it is a direct reflection. Bend this hand and pull it in front of your chest once, then push it out while stretching your elbow in a 45° direction and loudly say, “Yeah!” The problem is the shape of the left and right hands. One hand is the motor while the other acts as an electrical generator. Do you happen to remember which is which?

One acts as a motor that generates motion by flowing electricity whilst another acts as a generator, creating electricity via motion. For those who are right-handed, it’s easy to remember that your right hand is the one constantly in motion — that would be your “generator” — while the left hand would be your “motor.” Anyway, let’s get to the main show and try using a sensor on Raspberry Pi.

3. About the Sensor

Just thinking about sensors, you’ll imagine a part or device that electronically detects certain conditions. What kind of conditions are there? There are things like light, sound, temperature, humidity, tilt and other factors you’re familiar with in your everyday life. Particularly, alarms such as fire alarms are equipped with warning mechanisms that are triggered by temperature changes and smoke. Speaking of which, there are also light sensors equipped on digital cameras. Sensors have advanced so much that AI can even analyze images and recognize solid objects.

Imagine you’re on the street and you hear someone calling out for you, and you’re thinking, “Who is that person again?” If only our brains could connect with AI.
Anyway, there are various devices and part mechanisms that can be used in electronic work, along with things that can be connected to microcomputers like expansion parts and can obtain data as they are. Here we’ll be returning to the basics using a light sensor called a phototransistor. Previously, light sensors were referred to as CdS cells, meaning the mechanism decreases the resistance value when receiving light. As the name suggests, because it uses cadmium sulfide, and it is disappearing because it is not physically relevant.

about the sensors

NJL7502L Phototransistor (Left), 2 CdS Cell (Right)

So this phototransistor is made up of semiconductors, which is the same structure as a basic bipolar transistor. The one difference is that the input is light.

phototransistor polarity

Graphic Symbol

Looking at the graphic symbol, it looks like an NPN type transistor, but there is no B (base) terminal. Instead, there is an arrow. Since this arrow represents light, the input to B (base) is not the electric current but represents the incoming light radiation. In other words, strong and weak lights are outputted between C (collector) to E (emitter). Depending on the light, this function will amplify or switch.

Connect the Phototransistor to the GPIO

Let’s try connecting the phototransistor to the GPIO on Raspberry Pi. The language used will be Scratch while the sensor values will be the same with the switch at 1 and 0.

Connect the Phototransistor to the GPIO

It’s almost too simple, so you might be worried about how it works, but let’s give it a try.
When the light is not entering the phototransistor, since the input is set to Pullup, the switch is ON. In other words, the condition will become 1. If light enters, the input becomes negative due to the phototransistor, so switching is turned off and the value becomes 0, and vice versa.

set input GPIO to Pullup

Declare GPIO, set input GPIO to Pullup, and let the cat tell the resulting number. You can see that it will become 1 or 0 by covering the sensor part with your hand and blocking where the light hits. A light sensor was used here, but there are a variety of other ways you can play around with this. For example, if you use a temperature sensor thermistor, you can turn on the motor to send wind when the temperature rises, and it can be combined with a humidity sensor to provide a heat stroke alarm. GPIO input is quite convenient!

Sensor that Detects Objects by Light

In many cases, the phototransistor alone can actually affect the ambient light. Of course, it’s useless in the dark. So it would be efficient to combine LEDs to emit light and use them in pairs with light sources. There are several types of members in this pair, with the structure and detection method also being different.

Photointerrupters are installed in a straight line in the shape of an LED light directly inputted to the phototransistor. Some objects pass between them, and the object is then detected when it blocks the light. Since this kind of device is often found in factory lines and printers, chances are you won’t see them in person.

Photointerrupters

The photo reflector is installed in the same direction as the LED and phototransistor. Whenever an object passes through, it detects the light’s reflection. The sensors that are commonly used are sensors for automatic cleaning of public toilets, among other things.

photo reflector

Photo couplers are a pair of LED and phototransistors that doesn’t detect objects in between, but rather transmits signals by light. Because of this, it’s not a sensor, but we can view it in the same vein as using a light source and a light-receiving component. By transmitting signals without electrical connection, it is used for circuit safety and transmitting signals to circuits with different electrical characteristics.

Photo couplers

Connect the Phototransistor to the GPIO

Today, we’ll be using Rohm’s RPR-220 Photo Reflector. Since this photo reflector is a combination of an LED and transistor, let’s take a look at each characteristic.

Rohm's RPR-220 Photo Reflector

RPR-220

First, since the LED part is 1.34V50mA and the phototransistor part’s collector current is 300mA, the power supply of the LED uses a 3.3V Raspai power supply terminal, and a 51Ω current limiting resistor is connected to the LED part. Since this LED has infrared light, you cannot see it with your eyes, but if you look at it with a digital camera, you can see it is shining brightly.

Connect the Phototransistor to the GPIO

The phototransistor part will be the same as the circuit from before. Doing that, it will operate as a sensor. For the time being, we let the LED light up by itself. Of course, you can also use it like the previous motor.

Connect the Phototransistor to the GPIO

It will look like this when assembled on a breadboard.

assembled on a breadboard diagram

assembled on a breadboard

This is what Scratch will look like.
 scratch

Now, when something is placed in front of the sensor, the LED lights up.

LED lights up

Oh! It’s moving now!

The photo reflector has a structure in which the light-emitting part and the light-receiving part are installed separately in the package. Since the light is reflected, if the object comes in contact with the package itself, the reflected light cannot be read by the light-receiving unit. Six millimeters from the package seems to be appropriate for RPR-220. For example, it might be good to assume that something is placed through glass or acrylic.

4. Conclusion

This time we experimented working with sensor inputs, meaning that we now have a better idea of how to handle sensors through its simple mechanisms. However, I can’t be satisfied with only this. I would like to show what I can do by applying it, what interesting things I can make with it and actual pieces that may be made with them. Next time, we’ll be applying all the mechanisms we’ve learned up to now and go over the techniques and processes for building a piece.

It is important to experiment and prove principles and mechanisms, but I would like to expand on that by thinking more about what is possible while I keep creating.

DevicePlus Editorial Team
DevicePlus Editorial Team

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • Building Something Interesting Using SensorsBuilding Something Interesting Using Sensors
  • Learning About Ohm’s Law, GPIO and Transistors with Flashing LEDs on Raspberry PiLearning About Ohm’s Law, GPIO and Transistors with Flashing LEDs on Raspberry Pi
  • Introduction to Raspberry Pi 4: Tackling the Basic Electronic Kits With the Raspberry Pi 4!Introduction to Raspberry Pi 4: Tackling the Basic Electronic Kits With the Raspberry Pi 4!
  • Using LEDs and Motors on Raspberry Pi: How to Handle Larger CurrentsUsing LEDs and Motors on Raspberry Pi: How to Handle Larger Currents
  • Introduction to Raspberry Pi 4: Let’s Start Using the New “Raspberry Pi 4!”Introduction to Raspberry Pi 4: Let’s Start Using the New “Raspberry Pi 4!”
  • Digital Vivarium Box Powered by Solar Panels Using Arduino (Part 2)Digital Vivarium Box Powered by Solar Panels Using Arduino (Part 2)
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort