Back

Here is how you code the Jewelbots' Buzzer

The Buzzer class constructs objects that represent the buzzer attached to the physical Jewelbot. This allows you to control the short and long vibration taps your Jewelbot can make.

COMPONENT INTIALIZATION

Buzzer buzz; //naming the variable type and then the name of variable.

In order to use the Buzzer functions, you first need to initialize the library. This tells your program that you want to code around the Buzzer, then you can use the functions below to do cool things with LEDs!

The different functions are called the "API", because they are the way you interact with the device. APIs are ways you can work with different interfaces, sometimes in a computer and sometimes online.

API

.extra_short_buzz()

This function has your Jewelbot vibrate for an extra short amount of time (125 ms).

Buzzer buzz; buzz.extra_short_buzz();

.short_buzz()

This function has your Jewelbot vibrate for a short amount of time (250 ms).

Buzzer buzz; buzz.short_buzz();

.medium_buzz()

This function has your Jewelbot vibrate for a long amount of time (500 ms).

Buzzer buzz; buzz.long_buzz();

.long_buzz()

This function has your Jewelbot vibrate for an extra short amount of time (750 ms).

Buzzer buzz; buzz.long_buzz();

.extra_long_buzz()

This function has your Jewelbot vibrate for a short amount of time (1000 ms).

Buzzer buzz; buzz.extra_long_buzz();

.really_long_buzz()

This function has your Jewelbot vibrate for an extra long amount of time (1500 ms).

Buzzer buzz; buzz.really_long_buzz();

.custom_buzz(uint8_t amplitude, uint32_t milliseconds)()

This function creates a custom buzz! Amplitude is a measure of how strong the motor vibrates. Amplitude can be from 0 (no buzz) to 127 (max buzz). Jewelbots typically buzz right in the middle at an amplitude of 63. The amount of time the motor vibrates is measured in milliseconds. 40 ms is the minimum allowed and 2s (2000 ms) is the max for longevity.

Buzzer buzz; Buzzer buzz; buzz.custom_buzz(63, 500); // This will buzz at 50% strength for 1/2 second.