Moved Raspberry Pi remotely so that it can be LED attached with Python

Introduction

I bought a Raspberry Pi because I thought it could be applied in business. This time, we turned on the LED, which is the position of the tutorial. This is my first experience with electronic work. Please let us know your opinions and impressions.

We are using Windows as our main PC.

Remotely connect Raspberry Pi

Windows has a function called Remote Desktop that displays and operates other PCs. If you are using Windows 10, you can find this by searching from the search field next to the Windows icon.

001.png

In my case I access the Raspberry Pi via WIFI. You must enter the IP address as the computer name. This can be confirmed by the ipconfig command from the terminal screen inside the Raspberry Pi.

003.png

Below wlan0 above, the one described in inet is the IP address. Enter this. Next, the login screen by xrdp will be displayed. xrdp is a server program that provides the Microsoft Remote Desktop Protocol on Linux. Please install from the following command in the terminal on Raspberry Pi.

sudo apt-get install python-rpi.gpio

003.png

The image above is the login screen. By default, it is id: pi, password: raspberry. From a security point of view, I think this should be changed.

004.png

I was able to enter safely.

Make LED circuit

This time, I bought this to make a circuit for Raspberry Pi. For the time being, I made it a type that contains everything in one. https://www.amazon.co.jp/BONROB-Raspberry-%E3%83%96%E3%83%AC%E3%83%83%E3%83%89%E3%83%9C%E3%83%BC%E3%83%89-%E3%82%B8%E3%83%A3%E3%83%B3%E3%83%91%E3%83%BC%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC-RAB%E3%83%9B%E3%83%AB%E3%83%80%E3%83%BC/dp/B07P5LMVN1

Regarding LED lighting, I referred to here. http://make.bcde.jp/raspberry-pi/gpio%E3%81%A7led%E3%81%AE%E7%82%B9%E6%BB%85python/

Raspeberry Pi has a terminal called GPIO (“General Purpose Input / Output”) that performs input / output. I bought a Rapberry Pi 4, so it has 40 pins. The first thing I noticed is that none of these 40 points have the same function, and there are separate pins that must be used when you want to input or output.

002.png

In order to pass electricity (= hardware control) from the Rapberry Pi to the LED circuit through this GPIO, it is usually necessary to install a device driver. However, it can be controlled programmatically by using a command called GPIO.

006.png

This time, I assembled it as shown in this figure. The point to note is the orientation of the LED light electrodes. The longer leg is the anode terminal (+).  001.jpg

LED lit by Python program

Now, let's finally turn on the LED. You can turn on the LED with a command from the terminal, but this time we will use Python. Raspberry Pi 4 has an IDE called Thonny Python IDE installed, so run it from here.

In order to operate GPIO, it is necessary to install GPIO library. Install it with the following command on the terminal of Raspberry Pi.

 $ sudo apt-get install python-rpi.gpio

By the way, the program to actually turn on is as follows. This time, it blinks 5 times at a pitch of 2 seconds.

LED.py



import RPi.GPIO as GPIO
import time

GPIO.setmode(RPi.GPIO.BCM)
GPIO.setup(18, GPIO.OUT)

for x in xrange(5):
    GPIO.output(18, True)
    time.sleep(2)
    GPIO.output(18, False)
    time.sleep(2)
GPIO.cleanup()

I was able to turn it on safely.

007.png

At the end

This time, we blinked the LED, which is a tutorial for Raspberry Pi work. By doing it remotely, you can feel that you are operating from a farther position, which is fun. I would like to apply this further and create a mechanism that allows you to experience IoT, such as setting up a server on AWS and creating a website for pet monitoring.

Recommended Posts

Moved Raspberry Pi remotely so that it can be LED attached with Python
SSD 1306 OLED can be used with Raspberry Pi + python (Note)
[Python] Make a graph that can be moved around with Plotly
Python knowledge notes that can be used with AtCoder
File sharing server made with Raspberry Pi that can be used for remote work
It seems that Skeleton Tracking can be done with RealSense
Install Mecab and CaboCha on ubuntu16.04LTS so that it can be used from python3 series
[Raspberry Pi] Scraping of web pages that cannot be obtained with python requests + Beautiful Soup
Use vl53l0x with Raspberry Pi (python)
I made a shuffle that can be reset (reverted) with Python
Make a currency chart that can be moved around with Plotly (2)
Make a currency chart that can be moved around with Plotly (1)
I tried to expand the database so that it can be used with PES analysis software
・ <Slack> Write a function to notify Slack so that it can be quoted at any time (Python)
Use python on Raspberry Pi 3 to light the LED with switch control!
Mathematical optimization that can be used for free work with Python + PuLP
Draw a graph that can be moved around with HoloViews and Bokeh
Working with GPS on Raspberry Pi 3 Python
Since python is read as "Pichon", it can be executed with "Pichon" (it is a story)
I made a familiar function that can be used in statistics with Python
Read the image posted by flask so that it can be handled by opencv
[Hackathon] About making a tool that can be CD on Raspberry Pi [Convenient tool]
Use python on Raspberry Pi 3 and turn on the LED when it gets dark!
File types that can be used with Go
I tried L-Chika with Raspberry Pi 4 (Python edition)
Get CPU information of Raspberry Pi with Python
List packages that can be updated with pip
One-liner that outputs 10000 digits of pi with Python
Connect to MySQL with Python on Raspberry Pi
GPS tracking with Raspberry Pi 4B + BU-353S4 (Python)
Measure CPU temperature of Raspberry Pi with Python
[Python] Introduction to web scraping | Summary of methods that can be used with webdriver
Japanese can be used with Python in Docker environment
Color list that can be set with tkinter (memorial)
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Output to "7-segment LED" using python on Raspberry Pi 3!
Limits that can be analyzed at once with MeCab
Display USB camera video with Python OpenCV with Raspberry Pi
Let's operate GPIO of Raspberry Pi with Python CGI
Raspberry Pi with Elixir, which is cooler than Python
It was great to edit the Python file in the Raspberry Pi with Atom's remote function
Organic EL character display SO1602 Python library for operation implemented with AdaFruit specifications (for Raspberry Pi)
GPGPU with Raspberry Pi
DigitalSignage with Raspberry Pi
Format summary of formats that can be serialized with gensim
Update Python for Raspberry Pi to 3.7 or later with pyenv
Python beginner opens and closes interlocking camera with Raspberry Pi
I tried running Movidius NCS with python of Raspberry Pi3
Create an LCD (16x2) game with Raspberry Pi and Python
Run BNO055 python sample code with I2C (Raspberry Pi 3B)
getrpimodel: Recognize Raspberry Pi model (A, B, B +, B2, B3, etc) with python
Scripts that can be used when using bottle in Python
It's Halloween so I'll try to hide it with Python
I investigated the pretreatment that can be done with PyCaret
Let's make a diagram that can be clicked with IPython
Connect Raspberry Pi to Alibaba Cloud IoT Platform with Python
[Python] Draw elevation data on a sphere with Plotly and draw a globe that can be rotated round and round
I bought and analyzed the year-end jumbo lottery with Python that can be executed in Colaboratory
Understand the probabilities and statistics that can be used for progress management with a python program
[Python] A program that finds the maximum number of toys that can be purchased with your money