Monthly Archives: December 2018

New products: 16-channel QTR MD reflectance sensor arrays

via Pololu Blog

QTR-MD-16A Reflectance Sensor Array.

We now have 16-sensor, medium-density (8mm-pitch) versions of our new QTR reflectance sensor arrays. Like the versions already released, these new modules are available in analog and RC configurations and with two different sensor types, resulting in four new products in all:

Unlike the medium-density (MD) arrays we have released previously, which just use the high-density PCBs in partially populated configurations, these new 16-channel modules use PCBs specifically designed for an 8 mm pitch. As a result, these are the first MD versions that allow separate control of the odd and even emitters, which gives you extra options for detecting light reflected at various angles. They have the same board dimensions (125 × 16.5 mm) and mounting hole locations as the high-density (4mm-pitch) 31-channel arrays, but the pinout is different.

QTR-MD-16A Reflectance Sensor Array.

QTR-HD-31A Reflectance Sensor Array.

For more information on our new QTR sensor family, you can see some of our previous blog posts about the versions we have already released:

Don’t forget to get in on our QTR introductory promotion! Be one of the first 100 customers to use coupon code QTRINTRO and get any of these new sensors at half price! (Limit 3 per item per customer.)

Friday Product Post: Develop Something New for 2019!

via SparkFun: Commerce Blog

2018 is just about over, ladies and gentlemen, so let’s send it out with a bang! This week we have the new version of the HiFive in stock, and new Pycom boards!

HiFive1 - Arduino RISC-V Dev Board

HiFive1 - Arduino RISC-V Dev Board


The HiFive1 is a low-cost, Arduino-compatible development board featuring the Freedom E310, making it the best way to start prototyping and developing your RISC‑V applications. Not only can the HiFive1 help build RISC-V platforms, but it is also the first commercially available option to do so! The HiFive1 can simply be plugged into your computer via the micro USB port located to the front of the board. Additionally, the HiFive1 comes programmed with a simple bootloader and a demo software, so you aren’t restricted to the Arduino IDE.

Pycom FiPy

Pycom FiPy

Pycom GPy

Pycom GPy


With Sigfox, LoRa, WiFi, BLE and cellular LTE–CAT M1/NB1, the FiPy and GPy are the latest Pycom MicroPython or triple–bearer, MicroPython-enabled microcontrollers on the market today – the perfect enterprise grade IoT platform for your connected Things.

Pycom SiPy - 14dBm

Pycom SiPy - 14dBm

Pycom SiPy - 22dBm

Pycom SiPy - 22dBm


The Pycom SiPy are triple-bearer, MicroPython-enabled microcontrollers with Sigfox, Wi-Fi and Bluetooth. We have two options available when it it comes to the SiPy boards, a 14dBm model and a 22dBm model. With the latest Espressif ESP32 chipset, the SiPy offers a perfect combination of power, friendliness and flexibility. Create and connect things everywhere, fast.

Pycom Pysense

Pycom Pysense

Pycom Pytrak

Pycom Pytrak


Imagine a shield you can use with any of your Pycom multi-network modules: that’s what you get with Pysense and Pytrack – a leg up to get you off to a great start quickly. These little fellows fit all Pycom boards, and each contains a number of sensors.

Alright, folks! That’s it for this week and this year! As always, we can’t wait to see what you make! Shoot us a tweet @sparkfun, or let us know on Instagram or Facebook. We’d love to see what projects you’ve made!

We’ll be back next week with even more fantastic new products!

comments | comment feed

GetSparked Year in Review

via SparkFun: Commerce Blog

Back in May, a new collaboration between SparkFun and GroupGets called GetSparked kicked off as a new approach to getting your passion projects to market. GetSparked presents an opportunity to get your product on SparkFun’s catalog after a successful group buy campaign on GroupGets. Starting with GetSparked for new product introduction (NPI) is a low risk (and zero cost) way to get early market feedback on the demand for and utility of your product before you commit to higher volume production. As 2018 comes to a close, let’s take a look what worked, what didn’t, and what’s ahead for GetSparked.

alt text

After about 7 months of the program I think that it’s just now hitting its stride and is poised to grow in 2019. One product has already made its way from GroupGets to the SparkFun catalog and another one has a good shot. There are 10 new GetSparked candidates on GroupGets now with various levels of backing and a handful that have failed which is very OK in our book. It’s generally better and cheaper to “fail faster” than to drag things out with a product that doesn’t have market potential.

So what worked? The tiny Nerdonic Exen Mini 32-bit Cortex M0+ Arduino-compatible microcontroller development board was the first GetSparked entry on GroupGets to fund (2 rounds in fact). It’s friendly price, low target unit count, and low technical barrier of entry made it a no-brainer to easily get backers who almost all bought multiple units. After they shipped, we were cleared to make the intro to SparkFun for them, which was the fun part for us. We’ll see what happens next in 2019…

alt text

Nerdonic Exen Mini

Another product that completed the full journey to the SparkFun catalog was SparkFun’s own Spectral Triad spectroscopy sensor. The board features an innovative array of three spectral sensors paired with on-board illumination LEDs to give experimenters everything needed to make spectroscopic measurements with one compact “Qwiic” connect board. Hats off to SparkFun for “eating their own dog food” (as the saying goes) and using GetSparked to market validate their own new product. The Spectral Triad started as a “SparkX” product hence it debuted on GroupGets as a black PCB but now sits on the SparkFun shelf in classic red after funding over 50 units.

Following up on the Triad’s success, SparkFun is back again with a new campaign on GroupGets for The Prototype Hardware Alternate Reality Puzzle (HARP). This is a creative board calling for intrepid backers ready for an adventure. If you liked DEF CON 26’s badge or wish you had one, The Prototype HARP might be for you.

alt text

SparkX Spectral Triad

Another notable active GetSparked campaign is the I2S Mezzanine from the 96Boards Community Mezzanine Initiative. This board is a no-compromise audio development board designed to connect to a huge range of existing platforms from the 96Boards catalog. We’re excited to see an organic community of open source hardware enthusiasts using GetSparked to try and make their hard work more available and accessible to others. After working with this group for a few months now I can say that they are worthy of your support and this campaign could certainly use it. Step up and be a sponsor of this special initiative. We’d all regret it if it went away and these types of ecosystems can save you a lot of time for more sophisticated product development needs.

alt text

96Boards I2S Mezzanine

alt text

Holybro Pixhawk 4 Mini QAV250

Yet another active GetSparked campaign that deserves some attention comes from Holybro in the Pixhawk 4 Mini QV250 Complete Kit (above). The kit not only looks really fun to build but it’s a great way to get started with the Pixhawk 4 Mini autopilot system for smaller DIY quadcopters and drones.

While there are a few more active GetSparked campaigns that we could highlight, let’s quickly talk about the F-word. A failed GetSparked attempt does not prevent you from tweaking your product and messaging and coming back to try again. We in fact encourage that. Sometimes the marketing effort or timing is off or the price point and features just aren’t quite good enough to get backers to vote with their dollars. Don’t be discouraged when that happens. If you believed in your product enough to have made it, chances are that others will too but you you must find the right balance between features, user experience, and price. Another recommendation that we have to new entrants is to not get hung up on margin on GroupGets. Breaking even is a win if it means getting your product in actual customer hands to see how well it’s received before you go to high volume production. Focus on getting your product right before trying to maximize margin.

I’d like to close with if you’ve been on the sideline with a passion project that you’d like to get into the hands of customers, now is a good time to think about getting in the game with GetSparked. The collaboration already has a couple of wins and that number will certainly grown in 2019 as both GroupGets and Sparkfun remain committed to its success. Don’t wait, get started now!

comments | comment feed

Mathematical Color Fading

via SparkFun: Commerce Blog

Color and Light

As a kid, I’m sure that we all learned about colors, the color wheel, primary colors and mixing colors, and most of us learned this with paints of some kind. But paint mixing is different than light mixing, in that paint is subtractive, while light is additive. The primary colors in the subtractive color mixing system are red, yellow and blue (known as the RYB set), and the primary colors in an additive color mixing system are red, green and blue (known as the RGB set). This is because those colors are found in the photoreceptors of the human eye.

If you really want to become a super color nerd, you could look into the work of James Clerk Maxwell, or, to dig a little deeper, even the work of Thomas Young and Hermann von Helmholtz.

So what all of that means is that when you paint a surface, for example red, the paint is actually absorbing all of the colors hitting it except for red. The same with blue paint, or yellow or green. Which is why, when you add all of the paint colors together, you get black. Your mixture is absorbing every color.

Conversely, with light, you are hitting a surface with color, so the surface simply reflects that color back. Shine a light with a wavelength of 700nm against a surface, and the surface will reflect that light, and you will see red. Which is why, when you add all of the colors of light together, you get white.

RYB and RGB color wheels

Pigment color wheel on the left; light color wheel on the right.

The concept of color changing

Now that you’ve read up on the Young-Helmholtz trichromatic theory of color vision (and I’m sure you have), you should have a little better understanding of how we can paint with light. It really just comes down to adjusting the percentages of the three colors - red, green, and blue - between 0% and 100%, to achieve the desired color. It would seem to be pretty straightforward stuff, and there are sites that will easily give you both the HEX value (which would look like #FF9999), and the DEC value (expressed as an integer of each color between 0 and 255, like (255, 153, 153)).

Since each of the three colors uses 8 bits, that is how we wind up with 256 possible values for each. While creating any of the 16,777,216 possible colors (256 x 256 x 265, right?) is easy, what happens when we want to smoothly fade from one color to another? There are a couple of ways to do this, so we’re going to look at two options.

Sure it seems simple…

The first method is color fading at its most basic. We take our initial three values - red, green and blue - and adjust the numbers to our second values, so that they start at the same time and finish at the same time. As a simple example, let’s say that your color fade was moving red by +120, green by +15 and blue by -40. Red would start to fade up, then once it got to three, blue would fade down by one; and once red got to eight, green would fade up by one. Back in 2007, Clay Shirky wrote a nice Arduino sketch to do just that. He used percentages of each color, and then converted them to the necessary 0-255 range. And this makes sense; we all get that we can adjust our LED outputs from 0-255.

* Code for cross-fading three LEDs, red, green and blue (RGB) 
* To create fades, you need to do two things: 
*  1. Describe the colors you want to be displayed
*  2. List the order you want them to fade in
* A color is just an array of three percentages, 0-100, 
*  controlling the red, green and blue LEDs
* Red is the red LED at full, blue and green off
*   int red = { 100, 0, 0 }
* Dim white is all three LEDs at 30%
*   int dimWhite = {30, 30, 30}
* etc.
* Some common colors are provided below, or make your own
* In the main part of the program, you need to list the order 
*  you want to colors to appear in, e.g.
*  crossFade(red);
*  crossFade(green);
*  crossFade(blue);
* Those colors will appear in that order, fading out of 
*    one color and into the next  
* In addition, there are 5 optional settings you can adjust:
* 1. The initial color is set to black (so the first color fades in), but 
*    you can set the initial color to be any other color
* 2. The internal loop runs for 1020 interations; the 'wait' variable
*    sets the approximate duration of a single crossfade. In theory, 
*    a 'wait' of 10 ms should make a crossFade of ~10 seconds. In 
*    practice, the other functions the code is performing slow this 
*    down to ~11 seconds on my board. YMMV.
* 3. If 'repeat' is set to 0, the program will loop indefinitely.
*    if it is set to a number, it will loop that number of times,
*    then stop on the last color in the sequence. (Set 'return' to 1, 
*    and make the last color black if you want it to fade out at the end.)
* 4. There is an optional 'hold' variable, which pasues the 
*    program for 'hold' milliseconds when a color is complete, 
*    but before the next color starts.
* 5. Set the DEBUG flag to 1 if you want debugging output to be
*    sent to the serial monitor.
*    The internals of the program aren't complicated, but they
*    are a little fussy -- the inner workings are explained 
*    below the main loop.
* April 2007, Clay Shirky <> 

// Output
int redPin = 8;   // Red LED,   connected to digital pin 9
int grnPin = 9;  // Green LED, connected to digital pin 10
int bluPin = 10;  // Blue LED,  connected to digital pin 11

// Color arrays
int black[3]  = { 0, 0, 0 };
int white[3]  = { 100, 100, 100 };
int red[3]    = { 100, 0, 0 };
int green[3]  = { 0, 100, 0 };
int blue[3]   = { 0, 0, 100 };
int yellow[3] = { 40, 95, 0 };
int dimWhite[3] = { 30, 30, 30 };
// etc.

// Set initial color
int redVal = black[0];
int grnVal = black[1]; 
int bluVal = black[2];

int wait = 10;      // 10ms internal crossFade delay; increase for slower fades
int hold = 0;       // Optional hold when a color is complete, before the next     crossFade
int DEBUG = 1;      // DEBUG counter; if set to 1, will write values back via serial
int loopCount = 60; // How often should DEBUG report?
int repeat = 0;     // How many times should we loop before stopping? (0 for no stop)
int j = 0;          // Loop counter for repeat

// Initialize color variables
int prevR = redVal;
int prevG = grnVal;
int prevB = bluVal;

// Set up the LED outputs
void setup()
  pinMode(redPin, OUTPUT);   // sets the pins as output
  pinMode(grnPin, OUTPUT);   
  pinMode(bluPin, OUTPUT); 

  if (DEBUG) {           // If we want to see values for debugging...
    Serial.begin(9600);  // ...set up the serial ouput 

// Main program: list the order of crossfades
void loop()

  if (repeat) { // Do we loop a finite number of times?
    j += 1;
    if (j >= repeat) { // Are we there yet?
      exit(j);         // If so, stop.

* The program works like this:
* Imagine a crossfade that moves the red LED from 0-10, 
*   the green from 0-5, and the blue from 10 to 7, in
*   ten steps.
*   We'd want to count the 10 steps and increase or 
*   decrease color values in evenly stepped increments.
*   Imagine a + indicates raising a value by 1, and a -
*   equals lowering it. Our 10 step fade would look like:
*   1 2 3 4 5 6 7 8 9 10
* R + + + + + + + + + +
* G   +   +   +   +   +
* B     -     -     -
* The red rises from 0 to 10 in ten steps, the green from 
* 0-5 in 5 steps, and the blue falls from 10 to 7 in three steps.
* In the real program, the color percentages are converted to 
* 0-255 values, and there are 1020 steps (255*4).
* To figure out how big a step there should be between one up- or
* down-tick of one of the LED values, we call calculateStep(), 
* which calculates the absolute gap between the start and end values, 
* and then divides that gap by 1020 to determine the size of the step  
* between adjustments in the value.

int calculateStep(int prevValue, int endValue) {
  int step = endValue - prevValue; // What's the overall gap?
  if (step) {                      // If its non-zero, 
    step = 1020/step;              //   divide by 1020
  return step;

/* The next function is calculateVal. When the loop value, i,
*  reaches the step size appropriate for one of the
*  colors, it increases or decreases the value of that color by 1. 
*  (R, G, and B are each calculated separately.)

int calculateVal(int step, int val, int i) {

  if ((step) && i % step == 0) { // If step is non-zero and its time to change a     value,
    if (step > 0) {              //   increment the value if step is positive...
      val += 1;           
    else if (step < 0) {         //   ...or decrement it if step is negative
      val -= 1;
  // Defensive driving: make sure val stays in the range 0-255
  if (val > 255) {
    val = 255;
  else if (val < 0) {
    val = 0;
  return val;

/* crossFade() converts the percentage colors to a 
*  0-255 range, then loops 1020 times, checking to see if  
*  the value needs to be updated each time, then writing
*  the color values to the correct pins.

void crossFade(int color[3]) {
  // Convert to 0-255
  int R = (color[0] * 255) / 100;
  int G = (color[1] * 255) / 100;
  int B = (color[2] * 255) / 100;

  int stepR = calculateStep(prevR, R);
  int stepG = calculateStep(prevG, G); 
  int stepB = calculateStep(prevB, B);

  for (int i = 0; i <= 1020; i++) {
    redVal = calculateVal(stepR, redVal, i);
    grnVal = calculateVal(stepG, grnVal, i);
    bluVal = calculateVal(stepB, bluVal, i);

    analogWrite(redPin, redVal);   // Write current values to LED pins
    analogWrite(grnPin, grnVal);      
    analogWrite(bluPin, bluVal); 

    delay(wait); // Pause for 'wait' milliseconds before resuming the loop

    if (DEBUG) { // If we want serial output, print it at the 
      if (i == 0 or i % loopCount == 0) { // beginning, and every loopCount times
        Serial.print("Loop/RGB: #");
        Serial.print(" | ");
        Serial.print(" / ");
        Serial.print(" / ");  
      DEBUG += 1;
  // Update current values for next loop
  prevR = redVal; 
  prevG = grnVal; 
  prevB = bluVal;
  delay(hold); // Pause for optional 'wait' milliseconds before resuming the loop

Code by Clay Shirky, 2007

While this method is just fine for many (if not most) applications, it does have its drawbacks. Let’s say your favorite sportsball team wears royal blue and gold as their team colors. It would be cool for your LED wall to fade back and forth between the two colors, right? But what happens to the overall color when it gets about halfway through to fade? Using this mathematical formula, at about halfway through the fade you wind up with your LEDs emitting (138, 132, 116), which is about the least interesting gray color possible. Additionally, it drops the brightness of the LED down to about half.

Blue to Gold Fade

Mathematically accurate at its center, but a visual snoozer to be sure

Solving the issue with math!

Suppose that for your killer NYE party, which is always the most technologically advanced of any NYE party in your area, you want to fade your room lighting from Pantone’s 2018 color of the year, Ultra Violet, to their 2019 color of the year, Living Coral (and I mean, come on, why wouldn’t you want to do that?). Now you need to create a smooth fade from (95, 75, 129) to (250, 114, 104). We’ve learned that simply fading each of our three colors directly and simply can return some less than exciting moments through the middle of the fade, so how can we avoid this? By throwing a little trigonometry at it!

SFE Logo in Pantones

Pantone’s 2018 and 2019 colors of the year. I think here at SparkFun we’re just going to stick with red.

Now I know that even seeing the word “trigonometry” tends to elicit a fight-or-flight response from most people, but stay with me, this won’t be that terrible. We’re going to be using the sine function, but thanks to sin() within the Arduino IDE, we don’t have to do much math at all!

Okay, we’ll still need to do SOME math. Instead of using integers, we’re going to use floating-point values. In Arduino terms then, instead of using int, we’ll be using float, giving us the ability to use decimal points. This is important here, because A) we will be using things like Pi and radians, and will need numbers like 6.283, and B) sine uses a range of -1 to 1.

A quick sine primer

When you input a number into a sine function, you’re actually entering an angle. By running the angle from 0 to 359 (remember, in a circle, 0° and 360° are the same, so if we start at 0, we have to end at 359), we complete one full circle, and our sine wave completes one full circuit.

Sine Degrees

Degrees of a circle, and their corresponding sine wave

I mentioned that we were going to be using radians, and here’s why. Sin() doesn’t care about us and our degrees of a circle, sin() wants the information in radians. Since we know that a radian is a length on the arc of a circle equal to its radius, and that on any circle that equals about 57.2958°, and that it takes about 3.14159 radians to get halfway around the circumference of a circle, we can redraw our graph depicting radians just as our Arduino wants it.

sine graph

This is what a sine wave looks like in its natural habitat.

And finally, we know that our illumination range is from 0 to 255. We just need to map our output to meet this range. You may be familiar with the map() function in Arduino, but there’s a simpler way to do this in our case. The most basic equation for sin() is:

out = sin(in)

We can take our sine range of -1 to 1, and adjust it to anything we want, with this line:

out = sin(in) * range + offset

So if we want want the output of our LED to be 0 (off), we would need an input of 4.712. Or, if we wanted our led at 255 (full power), we would need an input of 1.570. But what if we wanted to go from 0 to 255? Do we need to go backward? Not at all. Since our sine wave is continuous (or cyclical), we can continue counting forward and just add Pi to our starting number. Try running this code:

void setup(){

  Serial.begin(9600); //Setting up our Serial conection


void loop()
 // do input, etc. here - as long as you don't pause, the LED will keep pulsing
  float out;
  static float in = 4.712;
  if (in < 7.853){ // the sum of 4.712 + 3.141
    in = in + 0.01; // not the most efficient, just keeping it clear for demo purposes
  out = sin(in) * 127.5 + 127.5; // this maps our sine wave, from -1 to 1, to out LED output, 0 - 250
  Serial.println(out); // prints the output
  delay(100); // just to give us a little breathing room

By watching the output to our serial monitor, we will see the numbers go from 0, when the input is 4.712, up to 255, when out input gets to 7.853. This gives us a little insight into how, when used for each of the three colors, this can give us a very nice, non-linear fade.

One thing to notice is the “static” modifier in the above declaration of “in.” If we didn’t use this, “in” would be initialized to 4.712 each time loop() loops, which would keep the LED output permanently at 0. By adding this modifier, you’re telling the compiler to not keep initializing that variable every time we go through the loop.

This is just a small peek into color changing by doing more than just moving linearly from one output number to another. If we are really to examine color and how it is perceived by the human eye, we have a lot more digging to do on the subject. Next time, we’ll not only play a little more with color changing with sine waves, but we’ll also examine playing with HSV - that’s hue, saturation, and value - to move through colors. Additionally, we’re also going to look into CIELAB color space. Because as our parents learned watching Schoolhouse Rock, knowledge is power!

comments | comment feed

New product: 5-Channel Reflectance Sensor Array for Balboa 32U4 Balancing Robot

via Pololu Blog

We now have a 5-Channel Reflectance Sensor Array designed specifically for use with the Balboa 32U4 Balancing Robot. The array mounts to the Balboa 32U4 control board and provides an easy way to add line sensing to the Balboa (but following a line while balancing is actually kinda hard—and that part is up to you, should you accept the challenge).

The array features five IR emitter/phototransistor pairs with dimmable brightness control similar to our line of QTR reflectance sensors.

As with all of our new products this year, we are offering an introductory special. The sensor by itself is already inexpensive, so just discounting that did not seem exciting enough. To make it more celebratory, we decided to offer a special promotion for the whole Balboa package: you can get a Balboa 32U4 robot kit with motors, wheels, and the new 5-Channel Reflectance Sensor Array for just $79! To get the discounted price, add this special promotion product bundle and coupon code BALBOAREFLECT to your cart. Offer is limited to the first 100 customers, limit one per customer. If you already have a Balboa, or if you want different motors or wheels than what’s included in the bundle, you can use coupon code BALBOAREFLECT2 to save 35% (limit 2 per item).

Closed December 25

via Pololu Blog

We will be closing early on Monday, December 24, so our same-day shipping cutoff will be noon Pacific time instead of the usual 2 PM. We will be closed for Christmas on Tuesday, December 25. Orders placed after noon Pacific time on Monday, December 24 will be shipped on Wednesday, December 26.

And last call for our Christmas sale — only about 12 hours to go! Merry Christmas!