Showing Colors

Introduction

Lights, similar to our Hello, World program, are a great way to output data! For this, we’ll be ultimately making a set of traffic lights that go from red > yellow > green. We’ll begin by learning how to let our Little Python show single colors first.

Components Needed

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

1

Finding Our Blocks

For our program, we will need blocks from the Libraries, Setup, and Outputs sections

2

Importing Libraries​

From the libraries category, we need to get these two blocks. Libraries are basically what allows your Little Python to know what components you will be working with! In this case, we simply want to control the NeoPixel through the Pin that it is connected to.

3

Setting Up the Connection

Now that our libraries are ready, it’s time to set up the NeoPixel! The Pin(12) denotes the pin that our NeoPixel is connected to while the 1 represents the number of “pixels” that we have. Let’s leave it as is for now!

4

Getting the Set Color Block

From the Outputs category, grab this block and put it into our workspace. The number on the left is not important for now; what we want to play with is the white square on the right. Give it a click or tap!

5

Choosing Our Color​

These are all the colors that the Little Python can show. For now, select the red (2nd row, 3rd column) color for our traffic light project.

6

Displaying The Color​

Finally, we need to tell the Little Python to display the color that we just selected. That can be done by telling it to “write” it to the NeoPixel. Drag this  next to your color selection block.

The Complete Code

What We Learned

  • We learned how to import and use libraries

  • We learned how to initialize the Little Python Brain’s NeoPixel

  • We learned how to choose and write a color to the NeoPixel

Lesson tags: basic, color, neopixel
Back to: Beginner > Traffic Lights

CONTACT US

    Log in with your credentials

    or    

    Forgot your details?

    Create Account