Book Image

Arduino BLINK Blueprints

By : Utsav Shah
Book Image

Arduino BLINK Blueprints

By: Utsav Shah

Overview of this book

Arduino is an open-source prototyping platform based on easy-to-use hardware and software. Arduino has been used in thousands of different projects and applications by a wide range of programmers and artists, and their contributions have added up to an incredible amount of accessible knowledge that can be of great help to novices and experts alike. Want to build exciting LED projects with Arduino? This book will be your companion to bring out the creative genius in you. To begin with, you will get introduced to the maker movement and the open source hardware development Arduino boards. You will then move on to develop a mood lamp and a remote-controlled TV backlight. As you progress through the book, you will develop an LED cube and will learn to use sound visualization to develop a sound-controlled LED Christmas tree. You will then move on to build a persistence of vision wand. At the end of each chapter, you’ll see some common problems, their solutions, and some workarounds.
Table of Contents (14 chapters)

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:

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...