Reader small image

You're reading from  Creative DIY Microcontroller Projects with TinyGo and WebAssembly

Product typeBook
Published inMay 2021
PublisherPackt
ISBN-139781800560208
Edition1st Edition
Tools
Right arrow
Author (1)
Tobias Theel
Tobias Theel
author image
Tobias Theel

Tobias Theel works as the Technical Lead and DevOps for a German FinTech startup fino and since 2020 he has also started working for RegTech startup, ClariLab, as Lead Software Engineer. Being a software architect and an expert for Go and TinyGo alongside C# and Java, he is also iSAQB certified. Theel is a highly enthusiastic community contributor and is among the top 10% responders in C# and Unity3D as well as top 20% responders in .NET, Go, and Visual Studio on StackOverflow. When not programming for fino or ClariLab, he can be found developing games, mainly at game jams such as the Ludum Dare Jam, where he develops games from scratch within 72 hours. As an active speaker at tech talks and a participant for numerous hackathons, Theel loves to share his knowledge of software development with fellow enthusiasts.
Read more about Tobias Theel

Right arrow

Controlling a buzzer

We are going to write a very simple buzzer library. We only want the buzzer to make any sound, regardless of the pitch. We start off by adding the buzzer to the circuit. To do so, follow these steps:

  1. Connect D4 from the Arduino to A31 on the breadboard using a jumper wire.
  2. Use a 100 Ohm resistor to connect E31 with G31 on the breadboard.
  3. Connect the VCC pin from the buzzer with J31.
  4. Connect the GND pin to GND on the power bus.

The circuit should now look like the following figure:

Figure 4.11 – Buzzer – image taken from Fritzing

As we have now added the buzzer to the circuit, we can now start to write our library.

Writing a buzzer library

The buzzer library will have two functions: Configure(), which sets up the pin, and the Beep() function, which will make the sound.

We start off by creating a new folder named buzzer inside the Chapter04 folder. Inside the new folder, create a file named...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Creative DIY Microcontroller Projects with TinyGo and WebAssembly
Published in: May 2021Publisher: PacktISBN-13: 9781800560208

Author (1)

author image
Tobias Theel

Tobias Theel works as the Technical Lead and DevOps for a German FinTech startup fino and since 2020 he has also started working for RegTech startup, ClariLab, as Lead Software Engineer. Being a software architect and an expert for Go and TinyGo alongside C# and Java, he is also iSAQB certified. Theel is a highly enthusiastic community contributor and is among the top 10% responders in C# and Unity3D as well as top 20% responders in .NET, Go, and Visual Studio on StackOverflow. When not programming for fino or ClariLab, he can be found developing games, mainly at game jams such as the Ludum Dare Jam, where he develops games from scratch within 72 hours. As an active speaker at tech talks and a participant for numerous hackathons, Theel loves to share his knowledge of software development with fellow enthusiasts.
Read more about Tobias Theel