Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arduino Wearable Projects

You're reading from  Arduino Wearable Projects

Product type Book
Published in Aug 2015
Publisher
ISBN-13 9781785283307
Pages 218 pages
Edition 1st Edition
Languages

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  },
 ...
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 $15.99/month. Cancel anytime}