Skip to content

11. Output devices

Individual Assignment

For this week, I have to add an output device to a microcontroller board that I have designed and program it to do something. There are many output devices so I wanted to practice with LED’s and in my investigation The Neopixel Strip caught my attention. So, let is start!

Neopixel

Neopixel is a brand that was registered by Adafruit Industries and is a group of RGB LEDs which can be controlled individually. It can be arranged in different ways. For example: The Neopixel has 3 pins: - GND Pin: Needs to be connected to GND (0V) - VCC; Needs to be connected to 5v - Din Pin; is the pin that receives the color signal. It should be connected to the Board Pin. - Do Pin; is the pin that sends the color signal.

This information is important because I have to design these pins on my board.

How the Neopixel works

The integrated circuit of each LED can store 3 bytes, one byte for each color because they are chained only the first LED is connected to the control pin, in this case, a digital pin of the board that I have to design. The board will receive the chain of all the colors according to the number of pixels that are connected and in turn the first LED will receive the information all the colors one after the other. When an LED receives 3 new bytes of information, it delivers to the next LED the 3 bytes that it previously contained, in this way when the board finishes sending all the colors through the data pin, the first LED would have received and sent all the colors. All these information is importantt because it will be used for programming part.

PCB Designing

Understanding how the Neopixel works, it was more easy to design the PCB. We must start with the schematic, this is a screenshot: As can be seen, I choosed to add a pin header 1x03 and one will be for the Neopixel.

Milling the board

I have been follow the same workflow for milling. Here, you can see the traces and outline as png format:

This the final result:

Programming

First, we have flash the board. Following the instructions of the week 4

I realized that the library of the neopixel had already installed:

And then I opened the example given in the library:

// Adafruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

#define PIN        8 //  The board pin which is connected to the NeoPixels


#define NUMPIXELS 12 // The numbers of neopixels attached to the board

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels

void setup() {
  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif

  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}

void loop() {
  pixels.clear(); // Set all pixel colors to 'off'

  // The first NeoPixel in a strand is #0, second is 1, all the way up
  // to the count of pixels minus one.
  for(int i=0; i<NUMPIXELS; i++) { // For each pixel...

    // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    // Here we're using a moderately bright green color:
    pixels.setPixelColor(i, pixels.Color(0, 150, 0));

    pixels.show();   // Send the updated pixel colors to the hardware.

    delay(DELAYVAL); // Pause before next pass through loop
  }
}

This is the final result:

Input Devices from Angel Erazo on Vimeo.

Group Assignment

Here is the link

Files


Last update: November 14, 2022