Apply the fan status on the motor would achieve the function switching fan! The while loop will repeat every 100ms (sleep(100) ). Everytime the user pressed the button, the fan will turn on and vice versa. We declare a variable fan_switch to store the status of the fan(connect to P12).
So we use write_digital function this time instead of analog_write in previous example. #USB LED FAN EDITOR DOWNLOAD CODE#Python Code of Demo 2 from microbit import *Ĭode Explanation of Demo2 In this example, we focus on whether the switch is toggled. But to make this fan more friendly just like a real fan, we can add a button to switch the fan on and off, so please follow the picture and connect a BOSON button to P12 port of the extension board. ![]() #USB LED FAN EDITOR DOWNLOAD HOW TO#We have learned how to program the motor rotating in certain power. The use of the function write_analog in the code is to continuously change the power, if we use write_digital, then we can control the fan on and off. This time duration is controlled by sleep(1000), you can modify the parameter to adjust the time. For example, while True is a forever-repeating loo, and the for speed in mode loop will change the mode every second. The loop in program means doing some job repeatedly under certain condition. Later, you can see a while loop within a for loop in it. Note that the max power value is 1023 and power under 700 may not be strong enough to drive the fan. These numbers represent the power of the motor, higher value means higher motor speed, therefore stronger. In order to represent the three power mode of the fan, we declare a variable named mode, which is a list of three number. Python Code of Demo 1 from microbit import *įirst we import all the functions from the MicroPython library. For the base, please feel free to design or modify, yours doesn’t have to be exactly the same with ours.Ĭonnect a BOSON DCmotor component to micro:bit extension board’s P8 port with a Boson cable. Click the flash button to upload program to micro:bit through USB cable.įirst add the motor component in the BOSON kit onto the middle base. #USB LED FAN EDITOR DOWNLOAD DOWNLOAD#Please download the proper installation file according to your operating system.Īfter the installation is finished, you can open the Mu editor as the picture below. #USB LED FAN EDITOR DOWNLOAD MAC OSX#It can run directly on Windows, Mac OSX and every Linux distributions. This editor is simple and specially designed for beginners. ![]() In addition to using the online version seen on the micro:bit website, we can also download the Mu Editor () which is highly recommended by MicroPython. Despite a bit difficult to learn, MicroPython is much more powerful than graphical block editor environment. The link is the document of MicroPython on micro:bit, there are detailed documentation of functions and APIs. MicroPython is based on Python, an easy-to-learn programming language, and can be implemented on micro-processor board like Micro:bit. Micro:bit officially recommends two programming environments: one is graphical JavaScript blocks editor, and the other is the MicroPython which would be used in this project. You can design your own fan, but please make sure there are enough room to put on four BOSON components, including sensors and motors. The main hardware in this article consists of LEGO bricks, please refer the following picture. And micro:bit would display the error message by the LED array if failed while uploading the program. Remember to keep the logo on the micro:bit downward. Please assemble the micro:bit with the boson shield like the following pictures. #USB LED FAN EDITOR DOWNLOAD SOFTWARE#Preparation After the introduction, now let's get started with some preparation on the software and hardware. For more information about the boson kit for micro:bit, please refer to this website. With the special design on the circuit interface, children without circuit background can easily plug and use it. Besides being compatible with LEGO bricks, user can also fix the components on metal plates.The magnetic base under Boson bricks enable user to assemble and disassemble easily. There are many electronic components in this kit, which are looks like bricks. The Boson Started kit for micro:bit is designed by DFRobot. In this project we used BOSON starer kit with our micro:bit to build our smart fan. Micro:bit is a small computer designed by BBC, one interested in it may refer to its official website for more information, there are rich interesting projects suitable for beginners. In this article, we will show you how to create a smart fan control system with BBC micro:bit.
0 Comments
Leave a Reply. |
Details
AuthorNikki ArchivesCategories |