4099 views|4 replies

693

Posts

7

Resources
The OP
 

Raspberry Pi (I) Using Python language to flash GPIO pins [Copy link]

  I have been learning about Raspberry Pi for a while recently, and I can't wait to turn on a lamp to try out the effect of Raspberry Pi. There are some differences between Raspberry Pi and MCU. 32 MCU can run some operating systems. When I was working on 32 MCU before, I also tried to run a system once, that is, I downloaded a routine program and burned it into the MCU in the fog. It is not interesting to work on MCU all the time, so I applied for a Raspberry Pi development board. Raspberry Pi runs on Linux operating system, so I have to learn Linux operating system. After getting Raspberry Pi, I can't wait to see its effect, so I started the first Raspberry Pi project - using Raspberry Pi Python language to realize GPIO pin flashing. Let me show you the effect I made: Use Python language to realize GPIO pin flashing The above video is a very basic effect diagram I achieved. Suddenly I found that Raspberry Pi is quite fun. I would like to share with you the pin diagram of Raspberry Pi. You can save this pin diagram, which is very useful. Below I would like to share with you the program code in the LED.py file I talked about in my demonstration video:
  1. import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(18,GPIO.OUT) while True: GPIO.output(18,GPIO.HIGH) time.sleep(0.05) GPIO.output(18,GPIO.LOW) time.sleep(0.05)
复制代码
The first line means inserting the GPIO module of the Raspberry Pi The second line means inserting the time control module The third line means setting the GPIO encoding mode to BCM encoding. There are two GPIO encoding methods for Raspberry Pi, one is BOARD encoding, the other is BCM encoding The fourth line means configuring GPIO to output mode The following is an infinite loop of the program, pulling up GPIO18 for a delay of 0.05s and then pulling down GPIO18 for another delay of 0.05s
This post is from Innovation Lab

Latest reply

Okay, that's awesome.  Details Published on 2019-5-31 16:12
 
 

172

Posts

0

Resources
2
 
Thanks
This post is from Innovation Lab
 
 
 

333

Posts

0

Resources
3
 
study
This post is from Innovation Lab
 
 
 

33

Posts

3

Resources
4
 
Okay, that's awesome.
This post is from Innovation Lab

Comments

Hahaha  Details Published on 2019-5-31 17:08
 
 
 

693

Posts

7

Resources
5
 
Hahaha
This post is from Innovation Lab
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list