You must first complete Looping Through Sounds before viewing this Lesson

Integrating NeoPixel

Introduction

Now that we have our looping buzzer, it’s now time to add the NeoPixel to the mix to complete our police siren.

Components Needed

  • Little Python Brain
  • A tablet/phone/laptop
Steps

1

Setting up the NeoPixel

Since we’ll be using the NeoPixel, we just need to add the import neopixel and the neopixel setup blocks from the Libraries and Setup categories respectively.

2

Setting red and blue

As for setting the colors, simply drag two change color blocks and np.write() blocks. Set one to red and one to blue.

3

Combining light and sound

Since we now know that the Note and Rest Durations in the bz.playNote blocks have a sleep function (see Playing a Beep for more info), we can just combine this with the NeoPixel blocks with no added sleep() blocks!

The Complete Code

Back to: Beginner > Police Siren
© 2020 Little Python

CONTACT US

    Log in with your credentials

    or    

    Forgot your details?

    Create Account