1.8 Service Bell

Today, we will use Micro Switch, speakers, audio amplifier module, Raspberry Pi and scratch to make a service bell.

Tap the Micro Switch to make the service bell sound.

../_images/1.8_header.png

Required Components

In this project, we need the following components.

../_images/1.8_component.png

It’s definitely convenient to buy a whole kit, here’s the link:

Name

ITEMS IN THIS KIT

LINK

Raphael Kit

337

Raphael Kit

You can also buy them separately from the links below.

COMPONENT INTRODUCTION

PURCHASE LINK

GPIO Extension Board

BUY

Breadboard

BUY

Jumper Wires

BUY

Resistor

BUY

Micro Switch

-

Capacitor

BUY

Audio Module and Speaker

-

Build the Circuit

../_images/1.8_fritzing.png

Load the Code and See What Happens

Load the code file (1.8_service_bell.sb3) to Scratch 3.

Press the micro switch and the service bell will ring once.

Note

If your Raspberry Pi is connected to a screen with speakers, it may cause no sound from this external speaker, please refer to Change Audio Output for the solution.

Also, if you want to adjust the volume level, please refer to Adjust Volume.

Tips on Sprite

Select Sprite1 and click Costumes in the top left corner; upload bell1.png and bell2.png from the ~/raphael-kit/scratch/picture path via the Upload Costume button; delete the default 2 costumes, and rename the sprite to bell.

../_images/1.8_travel1.png

In the Sounds option, upload the bell.wav from the ~/raphael-kit/scratch/sound path to Scratch 3.

../_images/1.8_travel2.png

Tips on Codes

../_images/1.8_travel3.png

When pin17 is high (the Micro switch is not pressed), switch the costume of the bell sprite to bell1 (released state).

../_images/1.8_travel4.png

Press the micro switch, gpio17 is low level. At this time, switch the costume of the bell sprite to bell2 (press state), and play a sound effect through the speaker.