Project 6 of 29
In Progress

LED RGB and Neopixel with Arduino

45-60 min

Ages 14+

What Will You Learn?

You will learn to program two different types of LEDs, an RGB and a neopixel, learning much more about electronics and programming.

Connect the RGB LED to Arduino

Step 1

Connect the RGB LED to your Arduino microcontroller; It has 4 pins that will go in different lines of our breadboard, connect it as in image 2.

Step 2

Also check the following tables for more details:

LED RGB

Arduino 

Second smallest pin

D9

Larger pin

GND

Second long pin

D10

Smaller pin

D11

Neopixel

Arduino 

V

3.3V

R

D2

B

D5

G

D3

Program the RGB LED

Step 3

Start programming the RGB Led, this means a red, green and blue LED, to be able to combine these three colors to produce more tones.

Define the variables at the top:

int redLed = 9;

int blueLed = 11;

int greenLed = 10;

And in the void setup section, write:

   pinMode(redLed, OUTPUT);

   pinMode(blueLed, OUTPUT);

   pinMode(greenLed, OUTPUT);

You just declared the variables: their name, where they are found and also the port type (output).

Step 4

In the void loop section, write:

   digitalWrite(redLed, HIGH);

   delay(500);

   digitalWrite(blueLed, HIGH);

   delay(500);

   digitalWrite(greenLed, HIGH);

   delay(500);

  “

Step 5

You have just programmed each of the LEDs to turn on, with a waiting time of 500 milliseconds. Verify your code, save it (LedRGB-Hello-World) and upload it to your Arduino, you will see how the Led turns color to color, and how the colors are combined.

Different On, Off, and Wait Combinations

Step 6

Play with different combinations, on, off and wait, below is an example, copy and paste it in the void loop section:

   digitalWrite(redLed, HIGH);

   digitalWrite(blueLed, LOW);

   digitalWrite(greenLed, LOW);

   delay(500);

   digitalWrite(blueLed, HIGH);

   digitalWrite(redLed, LOW);

   digitalWrite(greenLed, LOW);

   delay(500);

   digitalWrite(greenLed, HIGH);

   digitalWrite(redLed, LOW);

   digitalWrite(blueLed, LOW);

   delay(500);

Program the Neopixel

Step 7

Now program the Neopixel, they are individually addressable types of RGB LEDs, to program it start by writing variables like the other LEDs:

int redNeopixel = 2;

int greenNeopixel = 3;

int blueNeopixel = 5;

Step 8

Now in the “void setup” section we define our variables as output:

  pinMode(redNeopixel, OUTPUT);

  pinMode(greenNeopixel, OUTPUT);

  pinMode(blueNeopixel, OUTPUT);

Step 9

In the “void loop” section write:

  digitalWrite(redNeopixel, HIGH);

  digitalWrite(blueNeopixel, LOW);

  digitalWrite(greenNeopixel, LOW);

  delay(500);

  digitalWrite(blueNeopixel, HIGH);

  digitalWrite(redNeopixel, LOW);

  digitalWrite(greenNeopixel, LOW);

  delay(500);

  digitalWrite(greenNeopixel, HIGH);

  digitalWrite(redNeopixel, LOW);

  digitalWrite(blueNeopixel, LOW);

  delay(500);

A tip: to turn on your LED you write HIGH but you can also write 1 and to turn off you write LOW just like you can write 0.

Step 10

With your code finished, verify it, save it, and upload it to your Arduino microcontroller with the buttons at the top. Cool! you can see it work.

Further Resources

Learn More!

Take it Further?

To learn more about arduino, following the MoonMakers lessons, and learn more about the fascinating world of programming and create your own projects

About MoonMakers

MoonMakers — led by Camila and Diego Luna — are a community of creators passionate about knowledge. A Makerspace, an open space with different digital manufacturing machines. And a YouTube channel where we promote science, technology and the maker movement.

MoonMakers have collaborated with companies such as: Sesame Street, Make Community and in Mexico with Educational Television and Fundación Televisa, creating educational content.

We have given workshops throughout the Mexican Republic with: Talent Land, Secretary of Education in Jalisco, Conacyt, Centro Cultural España.

MoonMakers

Materials:

  • Arduino microcontroller (We will use the Arduino nano 33 loT, but you can use the Arduino microcontroller of your choice)
  • 1 RGB LED
  • 1 Neopixel
  • 2 resistors of 100 ohms
  • 1 220 ohm resistors
  • 8 cables
  • Breadboard
  • A micro usb cable
  • A computer, with the Arduino IDE

Vocabulary:

  • function: is a section of a program that calculates a value independently from the rest of the program
  • void setup: The setup () function is called when a sketch begins. Use it to initialize variables, pin modes, start using libraries, etc. The setup () function will only run once, after every power-up or reboot of the Arduino board.
  • void loop: After creating a setup () function, which initializes and sets initial values, the loop () function does just what its name suggests and repeats consecutively, allowing your program to change and respond. Use it to actively control the Arduino board.
  • int: Integers are your main data type for storing numbers.
  • pinMode: Sets the specified pin to behave as an input or an output.
  • digitalWrite: Write a HIGH or LOW value to a digital pin. Its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
  • delay: Pauses the program for the time (in milliseconds) specified as a parameter. (There are 1000 milliseconds in a second.)

See More Projects in these topics:

Electronics Engineering Programming

See More Projects from these themes:

The Shop (Makerspace)
MoonMakers
Somos una comunidad de creadores apasionados por el conocimiento. Un Makerspace, un espacio abierto con diferentes máquinas de fabricación digital. Y un canal de YouTube donde promovemos la ciencia, la tecnología y el movimiento maker.
Print Project

Maker Camp Project Standards

Based on NGSS (Next Generation Science Standards)

NGSS (Next Generation Science Standards)

The Next Generation Science Standards (NGSS) are K–12 science content standards. Learn more.

Forces and Motion

  • 3-PS2-3. Ask questions to determine cause and effect relationships of electric or magnetic interactions between two objects not in contact with each other.
  • HS-PS4-5. Communicate technical information about how some technological devices use the principles of wave behavior and wave interactions with matter to transmit and capture information and energy.

CCSS (Common Core State Standards)

The Common Core is a set of high-quality academic standards in mathematics and English language arts/literacy (ELA).

Measurement & Data

  • Grades K-2
    • CCSS.MATH.CONTENT.K.MD.A.1 Describe measurable attributes of objects, such as length or weight. Describe several measurable attributes of a single object.
    • CCSS.MATH.CONTENT.1.MD.A.1 Order three objects by length; compare the lengths of two objects indirectly by using a third object.
    • CCSS.MATH.CONTENT.1.MD.A.2 Express the length of an object as a whole number of length units, by laying multiple copies of a shorter object (the length unit) end to end; understand that the length measurement of an object is the number of same-size length units that span it with no gaps or overlaps.
    • CCSS.MATH.CONTENT.2.MD.A.1 Measure the length of an object by selecting and using appropriate tools such as rulers, yardsticks, meter sticks, and measuring tapes.
    • CCSS.MATH.CONTENT.2.MD.A.2 Measure the length of an object twice, using length units of different lengths for the two measurements; describe how the two measurements relate to the size of the unit chosen.
    • CCSS.MATH.CONTENT.2.MD.A.3 Estimate lengths using units of inches, feet, centimeters, and meters.
    • CCSS.MATH.CONTENT.2.MD.A.4 Measure to determine how much longer one object is than another, expressing the length difference in terms of a standard length unit.
  • Grades 3-5
    • CCSS.MATH.CONTENT.3.MD.B.3 Draw a scaled picture graph and a scaled bar graph to represent a data set with several categories. Solve one- and two-step "how many more" and "how many less" problems using information presented in scaled bar graphs.
    • CCSS.MATH.CONTENT.4.MD.A.1 Know relative sizes of measurement units within one system of units including km, m, cm; kg, g; lb, oz.; l, ml; hr, min, sec. Within a single system of measurement, express measurements in a larger unit in terms of a smaller unit.
    • CCSS.MATH.CONTENT.4.MD.C.5 Recognize angles as geometric shapes that are formed wherever two rays share a common endpoint, and understand concepts of angle measurement.
    • CCSS.MATH.CONTENT.5.MD.A.1 Convert among different-sized standard measurement units within a given measurement system (e.g., convert 5 cm to 0.05 m), and use these conversions in solving multi-step, real world problems.
    • CCSS.MATH.CONTENT.5.MD.C.3 Recognize volume as an attribute of solid figures and understand concepts of volume measurement.

Ratios & Proportional Relationships

  • Middle School
    • CCSS.MATH.CONTENT.6.RP.A.1 Understand the concept of a ratio and use ratio language to describe a ratio relationship between two quantities.
    • CCSS.MATH.CONTENT.6.RP.A.3 Use ratio and rate reasoning to solve real-world and mathematical problems, e.g., by reasoning about tables of equivalent ratios, tape diagrams, double number line diagrams, or equations.
    • CCSS.MATH.CONTENT.7.RP.A.1 Compute unit rates associated with ratios of fractions, including ratios of lengths, areas and other quantities measured in like or different units.
    • CCSS.MATH.CONTENT.7.RP.A.2 Recognize and represent proportional relationships between quantities.

K–12 Computer Science Framework

The K–12 Computer Science Framework is designed to guide computer science from a subject for the fortunate few to an opportunity for all. The guiding practices include:
  1. Fostering an Inclusive Computing Culture
  2. Collaborating Around Computing
  3. Recognizing and Defining Computational Problems
  4. Developing and Using Abstractions
  5. Creating Computational Artifacts
  6. Testing and Refining Computational Artifacts
  7. Communicating About Computing
You can download the complete framework here. You may also want to consider the International Society for Technology in Education Standards. The ISTE Standards provide the competencies for learning, teaching and leading in the digital age, providing a comprehensive roadmap for the effective use of technology in schools worldwide.

NGSS HS.Engineering Design

The Next Generation Science Standards (NGSS) are K–12 science content standards.
  • HS-ETS1-1. Analyze a major global challenge to specify qualitative and quantitative criteria and constraints for solutions that account for societal needs and wants.
  • HS-ETS1-2. Design a solution to a complex real-world problem by breaking it down into smaller, more manageable problems that can be solved through engineering.
  • HS-ETS1-3. Evaluate a solution to a complex real-world problem based on prioritized criteria and trade-offs that account for a range of constraints, including cost, safety, reliability, and aesthetics as well as possible social, cultural, and environmental impacts.
  • HS-ETS1-4. Use a computer simulation to model the impact of proposed solutions to a complex real-world problem with numerous criteria and constraints on interactions within and between systems relevant to the problem.
For additional information on using content standards with our projects please visit the Maker Camp Playbook.
Makeyland Graphic

Sign up for monthly project ideas for young makers from the leading maker educators.

FEEDBACK