Difference between revisions of "5 Light up all kinds of LED"
(→Use mian.py) |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[File:Webduino_gif.gif|thumb|Overview: [[BPI-Bit]]]] | ||
+ | [[File:Micropython3.png|thumb|[[1 Get the development suite]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[2 Wired connection board]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[3 Try burning the board]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[4 Hello, World!]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[5 Light up all kinds of LED]] ]] | ||
+ | |||
+ | |||
+ | [[File:Micropython4.png|thumb|[[1 Auto series one key burn]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[2 ESPBlocks Beginner's only]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[3 Mpfshell details]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[4 Pycharm IDE programming]] ]] | ||
+ | |||
+ | |||
+ | [[File:Micropython5.png|thumb|[[1. Panel scrolling text]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[2. Panel display images]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[3 Bottom IO port control]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[4 Panel key detection]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[5 Gets the board temperature]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[6 Play MIDI music]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[7 Photosensitive gesture]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[8. MPU-9250 9-axis sensor]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[9. Make a compass]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[10 Free to define gestures]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[11 Random number generator]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[12 S2m Scratch2]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[13 Codelab Scratch3]] ]] | ||
+ | |||
+ | [[File:Micropython6.png|thumb|[[1 The basic algorithm]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[2 WiFI wireless connection]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[3 WiFI wireless programming]] ]] | ||
+ | [[File:Micropython2.png|thumb|[[MQTT communication applications]]]] | ||
+ | |||
+ | |||
=Light up all kinds of LED= | =Light up all kinds of LED= | ||
Line 49: | Line 83: | ||
print('turn off') | print('turn off') | ||
led.value(0) # turn off | led.value(0) # turn off | ||
+ | |||
+ | [[File:Mian_light.png]] | ||
+ | |||
+ | *If you feel the effect is not obvious, you can write an infinite loop to see the effect. Please use Ctrl + C to stop, otherwise you cannot continue the operation. | ||
+ | |||
+ | from machine import Pin | ||
+ | import time | ||
+ | led = Pin(18, Pin.OUT) # get a led on gpio 18. | ||
+ | while True: | ||
+ | print('turn on') | ||
+ | led.value(1) # turn on | ||
+ | print('sleep 1s') | ||
+ | time.sleep(1) # sleep 1s | ||
+ | print('turn off') | ||
+ | led.value(0) # turn off | ||
+ | print('sleep 1s') | ||
+ | time.sleep(1) # sleep 1s | ||
+ | |||
+ | [[File:Blink_led.png]] | ||
+ | |||
+ | ==Learn the LED light array (NeoPixel) on the light panel== | ||
+ | |||
+ | *Ready the following code into main.py (\HowToCode\ 01.leds \rgb_lattice. Py) | ||
+ | |||
+ | from pixel import Pixel | ||
+ | View = Pixel() | ||
+ | RGB = (10, 10, 10) | ||
+ | View.LoadXY(2, 2, RGB) | ||
+ | View.Show() | ||
+ | |||
+ | *Execute using runfile main.py. | ||
+ | |||
+ | [[File:Pixel.png]] | ||
+ | |||
+ | At this point, the quick start of the tutorial has ended, from the lower toolbar back to the home page or read the material on the right, learn more basic, advanced, application and so on. |
Latest revision as of 02:37, 21 February 2019
Contents
Light up all kinds of LED
If Hello World is the beginning of religious programming for software programmers, Blink Led is the same for hardware programmers. All hardware programming starts with lighting a lamp.
So we started to prepare our hardware, and I was using a beta version 1.3. It is sufficient for the purposes of this chapter, and is common to subsequent boards. Therefore, we pay attention to progressive, first a lamp, and then a row of lights.
Use repl
- Go into repl mode
- input (after selecting the text to copy, right-click in the black box and paste)
from machine import Pin
- input again
Pin(18, Pin.OUT).value(1)
- Make sure that one of the lights on the panel is lit
- Just to make sure it's the light we're controlling,input
Pin(18, Pin.OUT).value(0)
- That's when you see it go out
Use mian.py
- Prepare the following code into the main.py file. Unlike the previous one, this effect is continuous. It will make the light on and wait for one second before it goes off.
from machine import Pin import time led = Pin(18, Pin.OUT) # get a led on gpio 18. print('turn on') led.value(1) # turn on print('sleep 1s') time.sleep(1) # sleep 1s print('turn off') led.value(0) # turn off
- If you feel the effect is not obvious, you can write an infinite loop to see the effect. Please use Ctrl + C to stop, otherwise you cannot continue the operation.
from machine import Pin import time led = Pin(18, Pin.OUT) # get a led on gpio 18. while True: print('turn on') led.value(1) # turn on print('sleep 1s') time.sleep(1) # sleep 1s print('turn off') led.value(0) # turn off print('sleep 1s') time.sleep(1) # sleep 1s
Learn the LED light array (NeoPixel) on the light panel
- Ready the following code into main.py (\HowToCode\ 01.leds \rgb_lattice. Py)
from pixel import Pixel View = Pixel() RGB = (10, 10, 10) View.LoadXY(2, 2, RGB) View.Show()
- Execute using runfile main.py.
At this point, the quick start of the tutorial has ended, from the lower toolbar back to the home page or read the material on the right, learn more basic, advanced, application and so on.