.. note:: Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts. **Why Join?** - **Expert Support**: Solve post-sale issues and technical challenges with help from our community and team. - **Learn & Share**: Exchange tips and tutorials to enhance your skills. - **Exclusive Previews**: Get early access to new product announcements and sneak peeks. - **Special Discounts**: Enjoy exclusive discounts on our newest products. - **Festive Promotions and Giveaways**: Take part in giveaways and holiday promotions. 👉 Ready to explore and create with us? Click [|link_sf_facebook|] and join today! .. _1.13_scratch: 1.13 Doorbell ================== Today we will make a doorbell, click the button3 sprite on the stage, the buzzer will sound; click again, the buzzer will stop sounding. .. image:: img/1.13_header.png Required Components ------------------------------ In this project, we need the following components. .. image:: img/1.13_list.png It's definitely convenient to buy a whole kit, here's the link: .. list-table:: :widths: 20 20 20 :header-rows: 1 * - Name - ITEMS IN THIS KIT - LINK * - Raphael Kit - 337 - |link_Raphael_kit| You can also buy them separately from the links below. .. list-table:: :widths: 30 20 :header-rows: 1 * - COMPONENT INTRODUCTION - PURCHASE LINK * - :ref:`cpn_gpio_extension_board` - |link_gpio_board_buy| * - :ref:`cpn_breadboard` - |link_breadboard_buy| * - :ref:`cpn_wires` - |link_wires_buy| * - :ref:`cpn_resistor` - |link_resistor_buy| * - :ref:`cpn_buzzer` - \- * - :ref:`cpn_transistor` - |link_transistor_buy| Build the Circuit --------------------- .. image:: img/1.13_image106.png Load the Code and See What Happens ----------------------------------------- Load the code file (``1.13_doorbell.sb3``) to Scratch 3. Click on the green flag on the stage. When we click on the Button 3 sprite, it will turn blue and then the buzzer will sound; when we click again, the **Button3** sprite reverts to gray and the buzzer stops sounding. Tips on Sprite ---------------- Delete the default sprite, then choose the **Button 3** sprite. .. image:: img/1.13_scratch_button3.png Then set the size to 200. .. image:: img/1.13_scratch_button3_size.png Tips on Codes -------------- .. image:: img/1.13_buzzer4.png :width: 400 This block allows you to switch the sprite's costume. .. image:: img/1.13_buzzer5.png :width: 400 Set gpio17 to low to make the buzzer sound; set it to high and the buzzer will not sound. The **status** switch is used here, and we will use a flowchart to help you understand the whole code. When the green flag is clicked, the **status** will be set to 0 first, and wait for the sprite to be clicked at this time; if **button3** sprite is clicked, it will switch to costume as **button-b** costume (blue) and the **status** will be set to 1. When the main program receives the **status** as 1, it will let the buzzer sound at 0.1s interval. If **button3** is clicked again, it will switch to **button-a** costume (gray) and **status** will be set to 0 again. .. image:: img/1.13_scratch_code.png