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.

Wednesday, March 23, 2016

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: