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.
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.
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.
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
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.
I was able to enter safely.
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.
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.
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 (+).
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.
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