SlideShare a Scribd company logo
1 of 30
By: Andrew Tuline
A Fast Introduction to the Arduino
And Addressable LED Strips
Spark FUN
The Arduino Family
Early Projects
Too Many Pins
Someone has more skills, patience and time than I do!
Addressable LED Strips
• Addressable LED strips provide circuitry to
communicate serially
• Each LED has a chip to receive, decode, drive
LED’s and propagate data
Form Factors
Also 30, 60, 144 pixels/m
Enter Adafruit
• Adafruit has branded
WS2812’s and
APA102C’s
• They are called
NeoPixels and DotStars
Adafruit sells addressable LED’s in many shapes and sizes!
NeoPixels vs. DotStars
DotStars
• Data and clock pin
• High data rate
• Interrupt compatible
• More $$
• Currently strip only
• APA102C
https://learn.adafruit.com/adafruit-dotstar-leds/overview
NeoPixels
• Data pin only
• Slow data rate
• Not interrupt compatible
• Less $$
• Strips and more
• WS2812 & WS2812B
A Typical Addressable Strip
Strips include:
• WS2812, WS2812B
• APA102, APA102C
• WS2801, others . .
12V accent lighting strips don’t count!
Simple APA102C Connection
D12 –
D11 –
5V –
Gnd –
Vin –
Data in
Clock in
5V
Gnd, Battery -
Battery +
If using the Arduino 5V pin, keep the strip SHORT and reduce brightness!
Addressable LED Libraries
• Adafruit NeoPixel library
• Adafruit DotStar library
And then there’s:
• FastLED
Why FastLED?
• FastLED is a fast, easy-to-use Arduino library for
programming addressable LED strips.
• It supports multiple microcontroller platforms.
• It supports multiple addressable LED types.
• It has a lots of of function calls.
• FastLED is used by thousands of developers.
• The developers count clock cycles.
Do a YouTube search for ‘FastLED’
Downloading FastLED
• Follow the link at www.fastled.io
• The current version is on GitHub at:
https://github.com/FastLED/FastLED
• Download the zip file
• Extract the directory FastLED-master.
• Rename the directory from:
FastLED-master to FastLED
• Place that directory into:
C:Program Files(x86)Arduinolibraries
I use the development version (currently 3.1)!
FirstLight Example
• In the Arduino IDE, select
‘File | Examples | FastLED | FirstLight’
• I’m using APA102C, so I need to change some
definitions
We need to configure it for our LED strip!
Modified FirstLight Code
#include "FastLED.h"
#define NUM_LEDS 20
#define DATA_PIN 12
#define CLOCK_PIN 11
uint8_t max_bright = 64;
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS);
FastLED.setBrightness(max_bright);
}
void loop() {
for (int count = 0; count < NUM_LEDS; count++) {
leds[count] = CRGB::White;
FastLED.show();
delay(100);
leds[count] = CRGB::Black;
}
} The white LED should march across the array.
// Include the library
// Number of LED’s
// Our data pin
// Our clock pin
// Define brightness limiter
// Define the LED array
// Run once
// Initialize the LED library
// Limit the brightness
// Run continuously
// Cycle through all LED’s
// Set the current one white
// Show it
// Wait for a bit
// Set it to black
Setting LED values
• leds[9] = CRGB::Cyan; // Web colours
• leds[9].g = 255; // Just set green
• leds[0] = CRGB(255,0,0); // CRGB values (red, green, blue)
• leds[0] = 0x0000ff; // Use a long hex value
Or via HSV
• leds[9] = CSHV(hue, sat, bright); // Each goes up to 255
FastLED provides lots more ways to assign colours to LED’s
FastLED Is Just Getting Started
FastLED contains a LOT of functions including:
• Random number generation
• Fast 8 and 16 bit basic math functions
• Fast trigonometry
• Setting RGB and HSV values
• fill_rainbow, fill_gradient, fading, scaling, blending, noise,
palettes, palette blending, beats and more. . .
• Power management
We’re talking loads of functionality and FAST
Rainbow March
#include "FastLED.h"
#define LED_DT 12 // Data & clock pin
#define NUM_LEDS 20 // Number of LED's
#define COLOR_ORDER BRG // Change the order as necessary
#define LED_TYPE WS2812 // What kind of strip are you using?
uint8_t max_bright = 64; // How bright do we want to go
struct CRGB leds[NUM_LEDS]; // Initialize our array
uint8_t thisdelay = 8; // A delay value for the sequence
uint8_t thishue = 0; // Starting hue value.
uint8_t deltahue = 5; // Difference in hue between LED’s
Use variables where possible
Rainbow March cont’d
void setup() {
LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(max_bright);
}
void loop () {
rainbow_march();
FastLED.show();
delay(thisdelay); // or FastLED.delay(thisdelay);
}
void rainbow_march() {
thishue++;
fill_rainbow (leds, NUM_LEDS, thishue, deltahue); // FastLED does the heavy lifting
}
It boils down to just a few lines of loop code
Power Managed Rainbow March
1) In setup add:
set_max_power_in_volts_and_milliamps(5, 500); // Power management set at 5V, 500mA.
2) Change delay from:
delay(thisdelay); // or
FastLED.delay(thisdelay);
To:
delay_at_max_brightness_for_power(thisdelay); // Power managed FastLED delay.
3) Change show from:
FastLED.show();
To:
show_at_max_brightness_for_power(); // Power managed display of LED's.
More FastLED Demos
• FastLED provides several demos with the library
• I’ve also written several demos downloadable at:
https://github.com/atuline/FastLED-Demos
• There’s loads of other demos available
The FastLED community is at Google+
My Demos include
• one_sine demo
• pop_fade_demo
• ripple
• two_sin_demo
• noise16_demo
• three_sin_demo
• rainbow_march_demo
• aalight
aalight provides many routines, IR, keyboard, serial and button input
• fht_log
• matrix_demo
• soundbracelet
• soundmems
• and more. .
High School Trigonometry
• An increasing linear input
value yields a sine wave
output value
• Map the output to
brightness or location
• Change frequency, phase,
amplitude
• Mix multiple sine waves
• 8 or 16 bit
Why count pixels when you can use sine waves
More Topics
• Power issues
• Data line conditioning
• Troubleshooting, getting support
• Diffusers
• 2D matrix
• POV
• Sound reactive, MSGEQ7 vs FFT
• Other platforms (ie. Teensy 3.1, Octo WS2811)
• IR and other kinds of control
• DMX
• Loop friendly routines
LED Research
• fastled.io
• github.com
• pastebin.com
• arduino.cc/tutorial
• playground.arduino.cc
• learn.adafruit.com
I mostly use my Google-fu
Sources for Parts
• Lee’s Electronics
• Adafruit
• Sparkfun
• eBay
• Aliexpress
All it takes is a VISA card and your imagination
Demo Time

More Related Content

Viewers also liked

Using arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsUsing arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsSudar Muthu
 
Arduino / ArduBlock の簡単なプログラムと回路の例
Arduino / ArduBlock の簡単なプログラムと回路の例Arduino / ArduBlock の簡単なプログラムと回路の例
Arduino / ArduBlock の簡単なプログラムと回路の例mitunaga
 
ブレッドボードの使い方と Arduino に簡単な回路をつける例
ブレッドボードの使い方と Arduino に簡単な回路をつける例ブレッドボードの使い方と Arduino に簡単な回路をつける例
ブレッドボードの使い方と Arduino に簡単な回路をつける例mitunaga
 
Arduino 入門
Arduino 入門Arduino 入門
Arduino 入門mitunaga
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerMujahid Hussain
 
Arduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoArduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoEoin Brazil
 

Viewers also liked (7)

Using arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsUsing arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of things
 
Arduino / ArduBlock の簡単なプログラムと回路の例
Arduino / ArduBlock の簡単なプログラムと回路の例Arduino / ArduBlock の簡単なプログラムと回路の例
Arduino / ArduBlock の簡単なプログラムと回路の例
 
ブレッドボードの使い方と Arduino に簡単な回路をつける例
ブレッドボードの使い方と Arduino に簡単な回路をつける例ブレッドボードの使い方と Arduino に簡単な回路をつける例
ブレッドボードの使い方と Arduino に簡単な回路をつける例
 
Arduino 入門
Arduino 入門Arduino 入門
Arduino 入門
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
 
PORSCHE Case Presentation
PORSCHE Case Presentation PORSCHE Case Presentation
PORSCHE Case Presentation
 
Arduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoArduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the Arduino
 

Similar to A Fast Introduction to Arduino and Addressable LED Strips

Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshopatuline
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuatorsEueung Mulyana
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdfJayanthi Kannan MK
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5Syed Mustafa
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
 
Micro Controller 8051 of Speedo Meter using KEIL Code
Micro Controller 8051 of Speedo Meter using KEIL CodeMicro Controller 8051 of Speedo Meter using KEIL Code
Micro Controller 8051 of Speedo Meter using KEIL CodeSunil Kumar R
 
IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019Jong-Hyun Kim
 
Udayan_219209024_DA1001_FTP.pptx
Udayan_219209024_DA1001_FTP.pptxUdayan_219209024_DA1001_FTP.pptx
Udayan_219209024_DA1001_FTP.pptxSyncrotrone
 
Arduino delphi 2014_7_bonn
Arduino delphi 2014_7_bonnArduino delphi 2014_7_bonn
Arduino delphi 2014_7_bonnMax Kleiner
 

Similar to A Fast Introduction to Arduino and Addressable LED Strips (20)

Iot 101
Iot 101Iot 101
Iot 101
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
Arduino
ArduinoArduino
Arduino
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
 
Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
 
Anup2
Anup2Anup2
Anup2
 
publish manual
publish manualpublish manual
publish manual
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
Micro Controller 8051 of Speedo Meter using KEIL Code
Micro Controller 8051 of Speedo Meter using KEIL CodeMicro Controller 8051 of Speedo Meter using KEIL Code
Micro Controller 8051 of Speedo Meter using KEIL Code
 
Led flash
Led flashLed flash
Led flash
 
IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019
 
Arduino: Arduino lcd
Arduino: Arduino lcdArduino: Arduino lcd
Arduino: Arduino lcd
 
EESS.pptx
EESS.pptxEESS.pptx
EESS.pptx
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
 
Udayan_219209024_DA1001_FTP.pptx
Udayan_219209024_DA1001_FTP.pptxUdayan_219209024_DA1001_FTP.pptx
Udayan_219209024_DA1001_FTP.pptx
 
Arduino delphi 2014_7_bonn
Arduino delphi 2014_7_bonnArduino delphi 2014_7_bonn
Arduino delphi 2014_7_bonn
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 

A Fast Introduction to Arduino and Addressable LED Strips

  • 1. By: Andrew Tuline A Fast Introduction to the Arduino And Addressable LED Strips
  • 2.
  • 6. Too Many Pins Someone has more skills, patience and time than I do!
  • 7. Addressable LED Strips • Addressable LED strips provide circuitry to communicate serially • Each LED has a chip to receive, decode, drive LED’s and propagate data
  • 8. Form Factors Also 30, 60, 144 pixels/m
  • 9. Enter Adafruit • Adafruit has branded WS2812’s and APA102C’s • They are called NeoPixels and DotStars Adafruit sells addressable LED’s in many shapes and sizes!
  • 10. NeoPixels vs. DotStars DotStars • Data and clock pin • High data rate • Interrupt compatible • More $$ • Currently strip only • APA102C https://learn.adafruit.com/adafruit-dotstar-leds/overview NeoPixels • Data pin only • Slow data rate • Not interrupt compatible • Less $$ • Strips and more • WS2812 & WS2812B
  • 11. A Typical Addressable Strip Strips include: • WS2812, WS2812B • APA102, APA102C • WS2801, others . . 12V accent lighting strips don’t count!
  • 12. Simple APA102C Connection D12 – D11 – 5V – Gnd – Vin – Data in Clock in 5V Gnd, Battery - Battery + If using the Arduino 5V pin, keep the strip SHORT and reduce brightness!
  • 13. Addressable LED Libraries • Adafruit NeoPixel library • Adafruit DotStar library And then there’s: • FastLED
  • 14. Why FastLED? • FastLED is a fast, easy-to-use Arduino library for programming addressable LED strips. • It supports multiple microcontroller platforms. • It supports multiple addressable LED types. • It has a lots of of function calls. • FastLED is used by thousands of developers. • The developers count clock cycles. Do a YouTube search for ‘FastLED’
  • 15. Downloading FastLED • Follow the link at www.fastled.io • The current version is on GitHub at: https://github.com/FastLED/FastLED • Download the zip file • Extract the directory FastLED-master. • Rename the directory from: FastLED-master to FastLED • Place that directory into: C:Program Files(x86)Arduinolibraries I use the development version (currently 3.1)!
  • 16. FirstLight Example • In the Arduino IDE, select ‘File | Examples | FastLED | FirstLight’ • I’m using APA102C, so I need to change some definitions We need to configure it for our LED strip!
  • 17. Modified FirstLight Code #include "FastLED.h" #define NUM_LEDS 20 #define DATA_PIN 12 #define CLOCK_PIN 11 uint8_t max_bright = 64; CRGB leds[NUM_LEDS]; void setup() { FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS); FastLED.setBrightness(max_bright); } void loop() { for (int count = 0; count < NUM_LEDS; count++) { leds[count] = CRGB::White; FastLED.show(); delay(100); leds[count] = CRGB::Black; } } The white LED should march across the array. // Include the library // Number of LED’s // Our data pin // Our clock pin // Define brightness limiter // Define the LED array // Run once // Initialize the LED library // Limit the brightness // Run continuously // Cycle through all LED’s // Set the current one white // Show it // Wait for a bit // Set it to black
  • 18. Setting LED values • leds[9] = CRGB::Cyan; // Web colours • leds[9].g = 255; // Just set green • leds[0] = CRGB(255,0,0); // CRGB values (red, green, blue) • leds[0] = 0x0000ff; // Use a long hex value Or via HSV • leds[9] = CSHV(hue, sat, bright); // Each goes up to 255 FastLED provides lots more ways to assign colours to LED’s
  • 19. FastLED Is Just Getting Started FastLED contains a LOT of functions including: • Random number generation • Fast 8 and 16 bit basic math functions • Fast trigonometry • Setting RGB and HSV values • fill_rainbow, fill_gradient, fading, scaling, blending, noise, palettes, palette blending, beats and more. . . • Power management We’re talking loads of functionality and FAST
  • 20.
  • 21. Rainbow March #include "FastLED.h" #define LED_DT 12 // Data & clock pin #define NUM_LEDS 20 // Number of LED's #define COLOR_ORDER BRG // Change the order as necessary #define LED_TYPE WS2812 // What kind of strip are you using? uint8_t max_bright = 64; // How bright do we want to go struct CRGB leds[NUM_LEDS]; // Initialize our array uint8_t thisdelay = 8; // A delay value for the sequence uint8_t thishue = 0; // Starting hue value. uint8_t deltahue = 5; // Difference in hue between LED’s Use variables where possible
  • 22. Rainbow March cont’d void setup() { LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); FastLED.setBrightness(max_bright); } void loop () { rainbow_march(); FastLED.show(); delay(thisdelay); // or FastLED.delay(thisdelay); } void rainbow_march() { thishue++; fill_rainbow (leds, NUM_LEDS, thishue, deltahue); // FastLED does the heavy lifting } It boils down to just a few lines of loop code
  • 23. Power Managed Rainbow March 1) In setup add: set_max_power_in_volts_and_milliamps(5, 500); // Power management set at 5V, 500mA. 2) Change delay from: delay(thisdelay); // or FastLED.delay(thisdelay); To: delay_at_max_brightness_for_power(thisdelay); // Power managed FastLED delay. 3) Change show from: FastLED.show(); To: show_at_max_brightness_for_power(); // Power managed display of LED's.
  • 24. More FastLED Demos • FastLED provides several demos with the library • I’ve also written several demos downloadable at: https://github.com/atuline/FastLED-Demos • There’s loads of other demos available The FastLED community is at Google+
  • 25. My Demos include • one_sine demo • pop_fade_demo • ripple • two_sin_demo • noise16_demo • three_sin_demo • rainbow_march_demo • aalight aalight provides many routines, IR, keyboard, serial and button input • fht_log • matrix_demo • soundbracelet • soundmems • and more. .
  • 26. High School Trigonometry • An increasing linear input value yields a sine wave output value • Map the output to brightness or location • Change frequency, phase, amplitude • Mix multiple sine waves • 8 or 16 bit Why count pixels when you can use sine waves
  • 27. More Topics • Power issues • Data line conditioning • Troubleshooting, getting support • Diffusers • 2D matrix • POV • Sound reactive, MSGEQ7 vs FFT • Other platforms (ie. Teensy 3.1, Octo WS2811) • IR and other kinds of control • DMX • Loop friendly routines
  • 28. LED Research • fastled.io • github.com • pastebin.com • arduino.cc/tutorial • playground.arduino.cc • learn.adafruit.com I mostly use my Google-fu
  • 29. Sources for Parts • Lee’s Electronics • Adafruit • Sparkfun • eBay • Aliexpress All it takes is a VISA card and your imagination

Editor's Notes

  1. - Who's already using an Arduino? - Who's already using addressable LED's? - Adafruit library? FastLED?
  2. A trade-off between time and money.
  3. Let’s go through some menu items.
  4. You can reduce pin counts by multiplexing (or strobing various pins). Use shift registers to support all these pins.
  5. I’m not talking the 12V analog RGB strips. One or two pins can support a lot of LED’s, each with a unique colour.
  6. Use Neopixels where you want multiple lines. Use DotStars for POV and for use with interrupt driven libraries, i.e. IR.
  7. That would be 5V, not 7V, not 12V. APA102C is round, has 6 pins WS2812 is LED+chip and has 6 pins WS2801 has separate LED+chip and 6 pins for LED. APA102 is square insides, WS2812B has 4 pins. WS2811 is a driver chip, while WS2812 is LED+driver chip (and 6 pins at that). https://cpldcpu.wordpress.com/2014/08/27/apa102/ (tims blog apa102)
  8. This is a simplified connection for short strips. I now use 5V USB rechargeable power banks for my short strips. Once you go over ~400mA to the strip, you should start using a dedicated 5V power supply.
  9. If you saw something cool at Burning Man, it probably used FastLED. Arduino’s, Adafruit Flora/Gemma & Trinket (ATTINY based), PJRC Teensy (ARM based)
  10. I use the development version 3.1
  11. FastLED supports multiple data pins.
  12. You need to add the ‘Wheel’ function for similar functionality with the Neopixel library.
  13. Great for portable strips.
  14. Perlin Simplex noise generation.
  15. Use sine waves to go back and forth
  16. http://ledwallproject.blogspot.ca/2014/05/making-5v-signals-for-ws2812-with-logic.html?m=1
  17. Power banks use rechargeable 18650 batteries. Power can be the biggest challenge. Long strips require extra power design. Resistor to the data lines (if long). Capacitors to the power lines. Apply power directly to each strip. Common grounds.