In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
How to use newbit to control neopixel, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Microbit / newbit can easily control neopixel lights (WS2812). Both micropython and javascript firmware include neopixel control, which is very easy to use.
In micropythhon, we can use any GPIO of microbit / newbit to control neopixel and control any number of colored lights.
For example:
Import neopixel
Np = neopixel.NeoPixel (pin1, 8)
Np [0] = (0,0,200)
Np [1] = (0,50,100)
Np [2] = (200,0,0)
Np.show ()
The function neopixel.NeoPixel (PIN, NUM) is used to create a neopixel object, which takes two parameters, the first is the GPIO, and the second is the number of colored lights.
The neopixel object is a list of tuples, and each list item is a tuple of three colors of RGB. The RGB parameter ranges from 0 to 255. the combination of the three colors has 256 x 256 x 256 = 1.67m colors.
The color parameter cannot be changed after the color parameter is written into the list, and the function show () needs to be called before it is updated. If you want to clear the lights, you can call the function clear ().
Graphical programming
Import neopixel
Import random
From microbit import * np = neopixel.NeoPixel (pin0, 8)
While True: np [(random.randint (0,7)] = ((random.randint (1,50)), (random.randint (1,50)), (random.randint (1,50) np.show () sleep
Programming with PXT block editor
Note: if you directly use the 3.3V power supply of microbit/newbit, be careful not to control too much LED, because the output power of LDO is limited, it is easy to cause overheat protection. It is best to use an external power source for more than 8 LED.
After reading the above, have you mastered how to control neopixel with newbit? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.