Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Arduino BLINK Blueprints

You're reading from   Arduino BLINK Blueprints Get the most out of your Arduino to develop exciting and creative LED-based projects

Arrow left icon
Product type Paperback
Published in May 2016
Publisher Packt
ISBN-13 9781785284182
Length 134 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Utsav Shah Utsav Shah
Author Profile Icon Utsav Shah
Utsav Shah
Samarth Shah Samarth Shah
Author Profile Icon Samarth Shah
Samarth Shah
Arrow right icon
View More author details
Toc

Developing an LED Christmas tree

We are now familiar with the concept of sound visualization. We have also learnt about controlling an LED matrix with music. Now, we will develop an LED Christmas tree, which will blink the LEDs as per the music beats.

To develop the basic circuit which responds to the beats, connect the circuit as shown in the following image:

Developing an LED Christmas tree

We will connect the audio input/mic to the analog pin 3 of the Arduino. We have connected LEDs to pins 5 to 12.

Once you have connected the circuit as mentioned, upload the following code on the Arduino:

#include <fix_fft.h>

int LEDPins[] = {5, 6, 7, 8, 9, 10, 11, 12};
int x = 0;
char imaginary[128], inputSignal[128];
char outputAverage[14];
int i = 0, inputValue;
#define AUDIOPIN 1

void setup()
{
  for (int i = 0; i < 8; i++)
  {
    pinMode(LEDPins[i], OUTPUT);
  }
  Serial.begin(9600);
}

void loop()
{
  for (i = 0; i < 128; i++) {
    inputValue = analogRead(AUDIOPIN);
    inputSignal[i] = inputValue;
    imaginary[i...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime