Book Image

Arduino Wearable Projects

Book Image

Arduino Wearable Projects

Overview of this book

Table of Contents (16 chapters)

Making a pattern


In the next code example, we will implement some pattern designs. These patterns are stored in arrays that correspond to the layout of the LEDs in the glasses. We can draw our patterns in code and later loop through the array and activate the LEDs. When the code is formatted as it is in the next sketch, we get a visual repetition of the pattern. A 0 in the array represents a turned off LED in the same position in the matrix and a 1 represent an LED that is turned HIGH:

/*Collect all the positive columns pins in one array. You need to make sure that these pins correspond to the direction you have placed the columns in the glasses*/
int powerPin[]={
  19,18,17,16,14,9,8,6,5,4,3};
/*Collect all the negative row pins in one array. Again make sure they are added in the same order corresponding to the glasses*/
int gndPins[]={
  12,11,10};
//This is a two dimensional array that holds the pattern
int pattern[3][11] = {
  {1,1,1,1,0,0,0,1,1,1,1  },
  {0,1,1,0,0,0,0,1,0,0,1  },
 ...