Want to look like an evil robot and/or a cool car from the 80's? By your command. I mean, OK Michael. I mean...oh never mind. Here's the code. It scans the pixels back and forth. This one looks best with the scans moving horizontally.

///////////////////////////////////////////////////////////////////////////////
// Circuit Playground Bike Light - Cylon
//
// Author: Carter Nelson
// MIT License (https://opensource.org/licenses/MIT)

#include <Adafruit_CircuitPlayground.h>

#define COLOR         0xFF0000    // change this to your favorite color
#define SCAN_RATE     100         // lower is faster

int pixel1;
int pixel2;

///////////////////////////////////////////////////////////////////////////////
void setup() {
  CircuitPlayground.begin();
  
  // Make it bright!
  CircuitPlayground.setBrightness(255);

  pixel1 = 0;
  pixel2 = 9;
}


///////////////////////////////////////////////////////////////////////////////
void loop() {
  // Scan in one direction
  for (int step=0; step<4; step++) {
    CircuitPlayground.clearPixels();
  
    CircuitPlayground.setPixelColor(pixel1, COLOR);
    CircuitPlayground.setPixelColor(pixel2, COLOR);

    pixel1 = pixel1 + 1;
    pixel2 = pixel2 - 1;
    
    delay(SCAN_RATE);    
  }

  // Scan back the other direction
  for (int step=0; step<4; step++) {
    CircuitPlayground.clearPixels();
  
    CircuitPlayground.setPixelColor(pixel1, COLOR);
    CircuitPlayground.setPixelColor(pixel2, COLOR);

    pixel1 = pixel1 - 1;
    pixel2 = pixel2 + 1;
    
    delay(SCAN_RATE);    
  }
}

This guide was first published on Apr 24, 2017. It was last updated on Apr 24, 2017.

This page (The Cylon) was last updated on Apr 21, 2017.

Text editor powered by tinymce.