Page 143 - KEC Khaitan C6 Flipbook
P. 143

2.  Code:






















                                     Block Code                                        Pin Diagram
                 3.  Test:

                 	   ∑  Press A: Motor turns on.
                 	   ∑  Press B: Motor turns off.



                        Component                    Micro:bit Pin                       Connection



                     Micro:bit              GND                              Ground (common)


                     Pin 1 (P1)             P1                               Base of NPN Transistor

                     NPN Transistor         Collector                        Negative terminal of DC motor

                     DC Motor               Positive terminal                Power supply (e.g., 3V or 5V)




                            SONAR AND SERVO EXTENSIONS IN MAKECODE FOR MICRO:BIT


                 The Sonar and Servo extensions in MakeCode facilitate the utilization of ultrasonic sensors and
                 servo motors with the Micro:bit, frequently employed in robotics, automation, and interactive
                 projects.
                 The Sonar extension operates with ultrasonic sensors, like the HC-SR04, which utilize sound waves

                 and the duration of the echo's return to ascertain distance. Projects requiring object detection or
                 distance measuring frequently use these sensors.
                 Servo  motors, which rotate  to  predetermined  angles  (usually  between  0°  and  180°),  can  be

                 controlled using the Servo extension. These motors are ideal for applications requiring precise
                 movement control, such steering systems, robotic arms, or machine moving parts.

                 Step  1   Adding the Extensions
                           ∑  Open MakeCode for Micro:bit at MakeCode for Micro:bit.



                                                                              Building Smart Solutions: An Introduction  141
   138   139   140   141   142   143   144   145   146   147   148