Sunday, May 1, 2016

Visualizing Music With FFT

This display is a 16x32 neopixel. It is displaying patterns generated by a Processing program doing real-time FFT (Fast Fourier transform). Basically it is visualizing music in the frequency domain using a polar-coordinate particle system.

The hardware makes use of Adafruit 8x8 neopixles, two 5v 10amp supplies, a FadeCandy controller, 16 AWG stranded wire , 20 AWG stranded wire, (2 - Female 2.1x5.5mm DC Power Cable Jack Adapter), and some plastic stand offs.

Friday, April 15, 2016

The Learning Lab Kit on a Shield for Arduino

Received this Learning Lab Kit on a Shield for Arduino from Programming Electronics Academy today and am very pleased.  This shield

The Learning Lab Kit on a Shield for Arduino is meant to help you save time – it basically pre-populates common circuits for you.

Circuits that you might already have learned quite well – like LED, potentiometer, or push buttons.

Instead of searching your shag carpet for the 220 ohm resistor that dropped last week, you simply use the Basic Electronics Arduino Shield – and it connects everything up for you.  No need to breadboard the circuits out.

So when you sit down for 20-30 minutes to practice coding on Arduino – then you spend the majority of the time getting to try new things, and less time repeating something you already know.




I couldn't wait to play with mine today







Want to save some time learning Arduino?
Join the thousands of awesome people to sign up for our 

Sunday, April 10, 2016

NeoPixel 16 Ring Fun

NeoPixels are fun and amazing.  In my project I connected 4 of the AdaFruit NeoPixel - 16 RGBW Leds together.  What caught my attention and curiosity was that you can control each of these RGBW Leds using just one wire.

This feat is accomplished with a very timing-specific protocol. Since the protocol is very sensitive to timing, it requires a real-time microconroller such as an AVR, Arduino, PIC, mbed, etc. It cannot be used with a Linux-based microcomputer or interpreted microcontroller such as the netduino or Basic Stamp.

How the protocol works can be found in the WS2812 data sheet.  For each RGB Led a stream of 24 bits will be sent, 8 bits for each color.  The value of each bit, 1 or 0, is determined by the timing of the square wave.

A logic 0 is represented by a signal that is high for .35 mircorseconds followed by a low of .8 microseconds

A logic 1 is represented by a signal that is high for .7 microseconds followed by a low for  .6 microseconds

So just in the process of updating a 16 LED RGB ring you will be sending 48 bytes of data, 3 bytes for each leds RGB value. Each byte contains a value of 0-255 indicating the value of intensity for that particular color (Red, Green or Blue).

Looking at the diagram above the transmission starts with D1 receiving the first 24 bits.  After that D1 will pass subsequent bits on to D2.  Once D2 receives it's 24 it starts passing subsequent bits onto D3.  Note that this is different than usual shift register operation.  The passing on will continue until the data line is held low for 50 microseconds.  Holding the data line low for 50 microseconds is a reset code indicating next sequence is for the WS2812 to process.



Generating the timing above is no easy feat and requires some very skilled hand-tuned assembly code that issues data to the LED drivers at a specific rate.  Fortunately, Phil Burgess / Paint Your Dragon, wrote a library for Adafruit that allows us mortals to control these beauties.

Below is the code and a video of my setup.  Codebender allows you to peek into the library files by holding down the CTRL key while clicking on the library header file.  In this case you would hold the CTRL key and click on "Adafruit_NeoPixel.h".  This will open a new tab with the NeoPixel library and related files.  From there look on the left hand side and select the Adafruit_NeoPixel.cpp file to explore and learn more about this awesome library.

Don't be afraid  If you have any questions please feel free to ask.



Want to save some time learning Arduino?
Join the thousands of awesome people to sign up for our 

Friday, April 8, 2016

Logging Environmental Data and Charting it with Google Charts

Today I have been experimenting with the Particle Photon and logging environment data to the internet via the Data.SparkFun.com.   Data.SparkFun.com is a free service for posting, storing, and reading sets of data. It’s powered by Phant, an open-source, Node.js-based tool that can be run on any server or computer.

Once the data data feed has some data  I can start charting it using a number of free services. Following Sparkfuns tutorial I am using Googles Charts to graph live data on my web site. Adding a barometric sensor to this wouldn't be hard and would make for some interesting weather studies.


Sparkfun Tutorial

Graphing Live Data With Google Charts Tutorial

Sample Live Chart, updated every 60 seconds, from my experiment

 I'll have this data logger along with a neopixel demo and other presentations on display at our Programming Electronics with Arduino meetup this Saturday 




Want to save some time learning Arduino?
Join the thousands of awesome people to sign up for our 

Tuesday, March 29, 2016

Understanding Data Types for variables

A data type in a programming language is a set of data with values having predefined characteristics. Examples of data types are: integer, floating point unit number, character, string, and pointer. Usually, a limited number of such data types come built into a language. The language usually specifies the range of values for a given data type, how the values are processed by the computer, and how they are stored.

In this video we well learn about the different data types you have access to in the Arduino IDE





Be sure to check out the the free Arduino Crash Course.

Saturday, March 26, 2016

Track A Car Using Tiny Arduino GPS with SD Card

This is a really cool project that was originally on Make as a GPS Cat Tracker.  Michael James, at the Programming Electronics Academy, put together an excellent 10 minute video showing you how easy it is to do this project.



Pretty cool huh?  If you enjoyed that you may also like the free Arduino Crash Course.

Friday, March 18, 2016

A great Arduino project book and site

I received a message on twitter asking if I knew how to test if a GSM Sim900 module was working.  I have not worked with that module hands on but did recall a great write up on it from a trusted source, John Boxall of http://tronixstuff.com.  I learned of John through Arduinos site under Manuals And Curriculum. His book, Arduino Workshop, was listed right along with Massimo Banzi's Getting Started With Arduino.

What impressed me most with this book is that all 65 of the projects from the book can be found on the authors website along with videos documenting his build of the project.
http://tronixstuff.com/.  Actually, each of the projects from the book are well documented on the site and has great educational content on it's own. 

In the spirit of Open Source John publishes all his stuff under "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License." allowing you to copy and redistribute the material in any medium or format long as you give credit to the original source and are not using for commercial purposes.

If you find the projects on http://tronixstuff.com/Johns site useful please consider buying his book.

Sunday, March 6, 2016

Particle Photon - The Buddy System: Publish and Subscribe

This is a demonstration of the Photons publish and subscribe features.  When the photon publishes an event to the cloud it makes that available to other devices that have subscribe to the event.  The other devices is not just limited to other photons but could also be internet connected smart phones ore web browsers.

In this example two photons are wired up to have an LED shining towards a photo resistor such that when an object comes between them the photon can detect the change on the photo resister.

The sample code in the photon documentation has each photon subscribing to the others unique event.  In the event handler the photon will check to see if the published event indicates the beam to be intact or broken.  If the beam is intact then the on board LED connected to D7 is turned off, if the beam is broken then the LED is turned on.

The main code on each photonsimply checks the status of the beam and publishes the status to the cloud.

Notice in the video how quickly the communication takes place.  To see the sample code visit the photon documentation.


Friday, March 4, 2016

A Simple LED Clock using Particle Photon

This is a simple LED clock I prototyped following Simon Monks post.

I am using a Particle Photon, a couple 4.7k resistors and a 7 Seg Display with an Adafruit I2C backpack.

The 7-segment LED backpack is obtaining it's power from the VIN pin of the Photon, which is 5 volts.  In order for the D0 (data) and D1 (clock) pins to interface with the backpack they are pulled high via 4.7k resistors through the 3V3 line.  These pullups are needed so that the Photon can drive a logic 1 on those lines.

Software

Go to http://particle.io and select the BUILD option to open the web IDE.

Create a new 'App' and call it LCD_Clock.

This project requires the SPARKTIME and ADAFRUIT-LED-BACKPACK LIBRARIES, add these by clicking the libraries button, find each of these libraries in turn and click USE THIS LIBRARY selecting your new LCD_Clock app when asked to select the app.

Now you can paste the following code into your App. Note that the includes should already be there if the libraries have been imported correctly.

You will need to change your time zone offset on the last line of setup.

That's it - the display should start as soon as the Photon resets.


#include "SparkTime/SparkTime.h"
#include "adafruit-led-backpack/adafruit-led-backpack.h"

Adafruit_7segment matrix = Adafruit_7segment();
UDP UDPClient;
SparkTime rtc;

unsigned long currentTime;
unsigned long lastTime = 0UL;
String timeStr;
int colon = false;

void setup() 
{
  matrix.begin(0x70);
  matrix.setBrightness(15);
  rtc.begin(&UDPClient, "north-america.pool.ntp.org");
  rtc.setTimeZone(0); // gmt offset
}

void loop() 
{
  currentTime = rtc.now();
  int min = rtc.minute(currentTime);  
  int hour = rtc.hour(currentTime);
  matrix.print(hour * 100 + min, DEC);
  colon = ! colon;
  matrix.drawColon(colon);
  matrix.writeDisplay();
  delay(500);
}

Check out Simons book for more experiments like this

Sunday, February 21, 2016

Syncing Oscilloscope To Interrupt Activity

Debugging interrupt service routines can be very tricky.  It's not like you can print out variabes to the serial port as you might when debugging code outside the interrupt.  One way you can can get some idea of what your code is doing in the ISR is to pulse one of the GPIO pins while in the ISR.  On the 16Mhz Arduino Uno this takes about 4 microseconds of overhead.  Another reason you might want to generate a pusle like this is to synchronize your oscilloscope with another event.
In the case of this experiment I wanted to see the clocking out of data to a 74HC595 shift register. 

This all started when I wanted to modify a sample sketch from the Sparkfun inventor kit to allow me to dynamically select and change the pattern being displayed on the 8 leds.  The experiment was set up so that the student was expected to un comment only the function to be used then re-upload the sketch to the arduino/redboard.

We had an extra Adafruit RGB LED Matrix that had an I2C interface and 5 menu buttons.  This worked very nicely because it only requires 2 pins from the redboard.  However, no matter what method you use to interact with the redboard in this example, you have the following problem:  The sketch as written uses delays between updating the led patterns.  In fact, the majority of what the sketch does is wait in delays.  If you try and add code that checks for key presses in the main loop of the program then you will have times that you need to hold the button or press the key for over half a second in order for the sketch to see it.   (See sketch that uses polling here)

There are are a few ways this can be solved.  1 - Have the keyboard / buttons generate an external interrupt to the redboard which cases a keyboard read and stores the key pressed in a buffer to be processed soon as the current led pattern function call is finished. (this would require additional hardware to route the physical interrupt signal). 2 - Set up a timer interrupt that polls the key for a keypressed, if one if found, set a flag and store the keypress for the sketch to process soon as the current led pattern function has finished.

Note that both 1 and 2 will involve some delay in the response time but will reduce the need of having the user hold the key or button until the redboard has a chance to check it.

A third way to do this is set up a interrupt that occurs ever millisecond, in the interrupt service routine you will check if the required time has elapsed and if so update the leds with the next pattern.  The main program of your loop will be devoted to interacting with the user.  Every millisecond the program will take 15 microseconds to decide if it needs to update the led patter on the 74HC595.  99% of the time it has nothing to do and returns.  When it does need to update the display it will take about 135 microseconds to shift the pattern out.

This does require rewriting the code.  No longer will you have functions you call for each pattern, but will keep a global variable telling the interrupt service routine which pattern is active and will decide how to do that within the interrupt service routine.  The advantage to doing this is the updating the display is happening in the background and allowing the main program to be more interactive with the user.

Here is a video of the project along with the code:  






Wednesday, February 10, 2016

Matrix keypad with 7 segment display (Arduino mini project)


3x4 Matrix keypad connected to an arduino. Displaying results of key pressed on a 7 segment led display via 74HC595 shift register which reduces the required pins of the 7seg display from 8 to 3.



I will be holding Arduino classes at Northbranch Library on the 2nd and 4th Saturdays .  Click Here For More Info. 

Come learn both theory and trouble shooting techniques.  If you cannot make it I can also skype.

Here is the video followed by the code used in this min project:




Monday, January 11, 2016

Arduino GPS LCD Clock

I built the Arduino GPS Clock by Tony DiCola over at Adafruit.  The clock was very cool, setting it's time from the satellites, however, I soon started feeling like I was wasting my GPS shield by only using it to get time.

So I decided to use the RGB LCD Shield which would allow me to display more information and be more interactive with the device.

At the time of this writing I have four boards stacked.  1) The arduino, 2) An Adafruit PowerBoost Shield with a 2000ma Lipo Battery, 3) The Adafruit Ultimate GPS Logger Shield and 4) the Adafruit RGB LCD Shield.

Having four boards stacked does make it bulky but I will be reducing that by dropping the Arduino Uno R3 board and replacing it's functionality with an Arduino Pro Mini placed in the prototype section of the GPS Logger Shield.

On the software side I currently have it displaying the time and date on its initial screen.  Other screens show "Latitude and Longitude", "Speed and Angle", Altitude and Satellites, then the Select button displays the message "This is a clock NOT a bomb. :-)

I plan to add some code to support logging GPS coordinates to the SD card.  Then I would like to try and implement Ladyada's logger which is interrupt driven to log data.  I would hope to accomplish a feature where background logging could be turned on and off.  The user in the foreground could set flags that would mark spots as important for the back ground logger to flag so that it could be recognized later when importing the data to google maps or some other gps mapping system.

Here is the current code on codebender

Lots to learn and try on this project.

UPDATE 4/10/16

The Arduino Pro Mini was put in place eliminating the need of the UNO R3.








Saturday, January 2, 2016

Adafruit Wave Shield

Here is a shield for Arduino that makes adding quality sound to your products easy.

It can play up to 22KHz, 12bit uncompressed audio files of any length. 

It's low cost, available as an easy-to-make kit. 

It has an onboard DAC, filter and op-amp for high quality output. 

Audio files are read off of an SD/MMC card, which are available at nearly any store. 

Volume can be controlled with the onboard thumbwheel potentiometer.

The shield comes with an Arduino library for easy use; simply drag uncompressed wave files onto the SD card and plug it in. Then use the library to play audio when buttons are pressed, or when a sensor goes off, or when serial data is received, etc. Audio is played asynchronously as an interrupt, so the Arduino can perform tasks while the audio is playing.

Click on the play button to watch a demo of the wave shield playing assorting audio through a small speaker.


    The shield comes with an Arduino library for easy use; simply drag uncompressed wave files onto the SD card and plug it in. Then use the library to play audio when buttons are pressed, or when a sensor goes off, or when serial data is received, etc. Audio is played asynchronously as an interrupt, so the Arduino can perform tasks while the audio is playing.

  • Can play any uncompressed 22KHz, 12bit, mono Wave (.wav) files of any size. While it isnt CD quality, it is certainly good enough to play music, have spoken word, or audio effects.
  • Output is mono, into L and R channels, standard 3.5mm headphone jack and a connection for a speaker that is switched on when the headphones are unplugged.
  • Files are read off of FAT16 formatted SD/MMC card.
  • Included library makes playing audio easy.

While the shield has been tested and works well, here are some points to keep in mind:
  • The audio playback library uses 10K of flash - so if you want to use an NG arduino, you'll need to upgrade to an Atmega168 chip.
  • About 600 bytes of SRAM are used to buffer the audio and keep track of file data, so RAM-heavy projects may not work well.
  • The shield can't play MP3, WMA, Ogg or other compressed audio files. It can only play uncompressed PCM/WAV files. Converting audio to WAV format is very easy, and is often the default format for many audio programs.
  • Files are stored as 8.3 name format, and can only be placed in the root directory. That means you can only have ~512 files (but they can be any size).
Ideas for what you can use it for...
  • Make a portable audio player
  • Use the AT&T text-to-speech site to make snippets of speech that you string together for a talking project, like..
  • Talking temperature sensor
  • Talking clock
  • Interfaces for sight-impared people
  • Doorbell that plays a cool tune
  • Jukebox/music-box that plays a song when its opened, or a coin is inserted
  • Security system that warns the intruder
  • Audio looper for musical effects and performances
  • Synthesizer with different sounds
  • Really freaky halloween props that scream
  • Display (like a point-of-sale box) that you can plug into to hear the message