Saturday, November 28, 2015

Infra Red Remote Controller Shield

Made use of The Forge makerspace at North Branch library to construct my first Arduino Shield. This shield adds 7 Status LEDs, an Infra Red LED, an Infra Red Receiver and a piezo buzzer.

Signal processing is handled by a great Arduino library written by Ken Shirriff and allows you to easily send and receive IR data.

In order to use the tone function I had to change which Timer the Infra Red Remote Library uses so it would not conflict. Other than that, the Infra Red Remote Library works very well. In the video below I test the shield using a sketch that plays a different tone for various buttons pressed on an old clarion remote control I found lying around.




Applications

Ken Shirrif used this library for several applications:



Other projects that use this library

Saturday, November 21, 2015

8x16 LED matrix controlled by 2 MAX7219's - requires only 3 Arduino pins

Expanding on my experiment with the MAX7219 controlling an 8x8 LED Matrix I added a second one. Both of the 8x8 displays and controllers were part of kits that couldn't fit neatly side by side, but the concept can still be demonstrated.

Using the circuit layout of the MAX7219 8X8 Red Dot LED Matrix Kit proved cumbersome as it didn't provide enough room to get the 8x8 LED panels close together and when you add additional devices the library expects to see them to the left of the previous device.  No big deal for testing. I would like to wire up a board that all three could neatly mount on and present a nice 8x24 display.

Here is a video of the 8x16 display created by cascading two of the MAX7219 controllers together.


UltraSonic Arduino How To - Parking your car with an Arduino

Using a Maxbotix Range Finder, Kevin Dahhar show you how to make a circuit that helps you back your car up into the garage, and put the Arduino into a super low power sleep when the circuit is not needed.

The Arduino only runs off of batteries and because it is kept in the super low power sleep mode the batteries last for months.

Only when the garage door is opened will the Arduino turn on due to the garage light activating a photocell and transistor circuit that signals an interrupt on the Arduino.

The code is well commented and very educational in itself.  You can look at it here

The video below is long but well worth the watch

Friday, November 20, 2015

MAX7219 and 8x8 LED Matrix on breadboard

I popped the MAX7219 and 8x8 LED Matrix from the kit and made it a little more social (watch video to see what I mean).  Using the MAX7219 requires only 3 pins from the arduino, a couple capacitors and resistor.  All the multiplexing is handled by the chip.  When writing to the device you shift out two bytes, one is the operand the second is the actual segment data.

The library hides that from you so you can simply turn on and off individual leds, rows or columns.

See my prior post, MAX7219 8X8 Red Dot LED Matrix Kit, for more details









Nootropic design 16x32 RGB backpack from Adafruit

Last night I put together the Nootropic design 16x32 RGB backpack from  Adafruit to power a 16x32 display (also obtained from Adafruit.

The backpack kit is only $12.95 at the time of this writing. connects to the back of the Adafruit 16x32 RGB LED Matrix Panel and is a very convenient way to control this awesome panel. The board is simply a small Arduino. You can easily program the board using the Arduino IDE. As you can see from the video below, it's possible to create great color animations, completely in Arduino programming!


Here is a video of mine running.  I cannot wait to dig further into this.


Tuesday, November 17, 2015

MAX7219 8X8 Red Dot LED Matrix Kit


After reading up on Project #21: Creating an LED Matrix in The Arduino Workshop I set out to find a 8x8 common cathode led matrix.  I saw this MAX7219 8X8 Red Dot LED Matrix Kit on Amazon and while I was looking to experiment with using two 74HC595's to control the rows and columns of the 8x8 matrix, this MAX7219 chip that did it all caught my curiosity.

So I ordered the kit.  :-)

Amazon Prime delivered quickly and the kit was relatively easy to solder.  Both the 8x8 display and the MAX7219 are socketed so you can easily remove them if you want to use in  a different project.  From the looks of it the board can be easily cascaded with other devices to create larger displays.  John Boxall does exactly that in his book The Arduino Workshop and posts a copy of the project online here.

The LedControl Arduino library has full support of the MAX7219 to control an 8x8 display.  The library does all the shifting out and multiplexing of row and column leds...All you do is tell it the row and column of the led you would like to turn on or off!

One single MAX7219 can also control up to 8 7segment displays.  Unlike my prior example, where each 7 segment display is driven by an individual 74HC595, the MAX7219 multiplexes the 7 segment displays so that only one is on at a time.  This cuts the current usage and because of the persistence of vision it appears that all 8 digits are on constantly.

So here is a peek at my finished MAX7219 8X8 Red Dot LED Matrix Kit running the test program.





#include "LedControl.h" //  need the library
LedControl lc=LedControl(12,11,10,1); // 

// pin 12 is connected to the MAX7219 pin 1 - Data In
// pin 11 is connected to the CLK pin 13
// pin 10 is connected to LOAD pin 12
// 1 as we are only using 1 MAX7219

void setup()
{
  // the zero refers to the MAX7219 number, it is zero for 1 chip
  lc.shutdown(0,false);// turn off power saving, enables display
  lc.setIntensity(0,8);// sets brightness (0~15 possible values)
  lc.clearDisplay(0);// clear screen
}
void loop()
{
  for (int row=0; row<8; row++)
  {
    for (int col=0; col<8; col++)
    {
      lc.setLed(0,col,row,true); // turns on LED at col, row
      delay(25);
    }
  }

  for (int row=0; row<8; row++)
  {
    for (int col=0; col<8; col++)
    {
      lc.setLed(0,col,row,false); // turns off LED at col, row
      delay(25);
    }
  }
}

Monday, November 16, 2015

Creating a Four Digit Display Using 74HC595 Shift Registers

My last experiment was with the three 74HC595s I was using to create the Knightrider effect on 24 leds.  In this experiment I am going to add another 74HC595 and use all four to control four common-cathode seven-segment LED displays.

To duplicate this setup you will need the following hardware:



Connections from Arduino in my setup

Pin 12 of the Arduino goes to pin 5 (the latch pin) on all of the 74HC595 shift registers.  When data is shifted out in serial to the shift registers this pin is first taken low then brought back high once the data has been shifted out and needs to be presented to the outputs of the shift registers.

Pin 11 of the Arduino goes to pin 6 on all of the 74HC595 shift registers.  This pin is clocked for each bit that is shifted in.  This pin is used by the ShiftOut() library function to clock data into the shift registers.

Pin 14 of the Arduino is being used as the Serial Data Input to the shift registers.

In order for the serial data to flow to all four of the shift regisers, pin 9 of shift register 1 (my least significant digit, holding the ones position) will connect to pin 14 of shift register 2 (digit holding the 10's position).  Pin 9 of shift register 2 will feed into pin 14 of shift register 3 (100's digit) and pin 9 of shift register 3 will feed into pin 14 of shift register 4 (1,000's digit).

Anytime I update the display it will involve four calls to the ShiftOut() routine:

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, digits[digit3]); 
shiftOut(dataPin, clockPin, LSBFIRST, digits[digit2]);
shiftOut(dataPin, clockPin, LSBFIRST, digits[digit1]);
shiftOut(dataPin, clockPin, LSBFIRST, digits[digit0]);
digitalWrite(latchPin, HIGH);

Connections to 7 Segment Display

LED pins A through G connect to pins Q0 through Q6 and DP connects to Q7 via current limiting resistors





Wiring the Display 

Each 7  segment display is going to have 8 resistors associated with it.  I placed those 8 above the display on the breadboard and connected them to the 7 segment in the following order:
DP (pin5), G (pin 10), F (pin9), E (pin 1), D (pin 2), C (pin 4), B (pin 6), A (pin 7).

Once I completed that wiring you might consider applying power to the board and testing by jumpering  5 volts to each resistor and confirming that the appropriate segment lights on your display.

Now that the resistors are in place and connected to the 7 segment displays you can connect the shift registers.  Each 7 segment display is being driven by it's own shift register.  Following the order laid out for the 7 segment display you will connect Q7 to the resistor on DP, Q6 to the resistor on G, Q5 to F, Q4 to E, Q3 to D, Q2 to C, Q1 to B and Q0 to A.

NOTE: A more practical way to have a 7 segment display would be using an Adafruit 0.56 4-digit 7-Segment Display w/I2C backpack and only using two pins on the Arduino.  The backpack also multiplexes the displays so the current requirements are much lower.  This experiment is an exercise in using the shift registers that were already breadboarded.

Here is a video of the display counting 0 through 13,000 with no delay between counts.  Once the count goes over 9,999 it will display dashes.


Here is the code I use to test the display.  I have it display dashes if the number is above 9,999, or out of range:


Wednesday, November 11, 2015

Kano Coding Kit For Ages 6-12


Kano is a computer and coding kit for all ages, all over the world. Our mission is to give people a simple, fun way to create with technology, and take control of the world around them.

The kit contains:
Raspberry Pi 2 Model B, ARM 900MHz Quad-Core CPU and 1GB RAM
8GB micro-SD Card preloaded with the latest Kano OS full of projects and games
Kano books, illustrated and intuitive
Wireless Kano Keyboard and mouse (USB RF & Bluetooth)
DIY speaker
Custom case, stencils and stickers!
HDMI cable
Wifi dongle
Mini-USB power supply (US plug)

Click Here To Get Yours




Tuesday, November 10, 2015

Playing night rider with three 74HC595s

Connected three 74HC595s in series and entertained myself by simulating KITT from Knightrider.  Would have hooked up the fourth one but was running out of realestate and LEDs.  I should have a another breadboard in a few days along with some 7 segment leds that I will be hooking up and controlling with the 74HC595s.
NOTE:  The breadboarding of 4 seven-segment displays and driving them with the 74HC595's is an exercise in digital electronics and programming not meant to be a recommendation for implementation in an actual project.  If you need a 7 segment display in your project I recommend using I2C like I am doing in this photo using the Adafruit 0.56 4-digit 7-Segment Display w/I2C backpack (assembly with soldering required).



Till then, enjoy the video and code.

UPDATE - Found that with zero delay the data is getting clocked to the registers at 58KHz.  I thought it would be faster but then if you divide 58Khz into the 16MHz clock of the arduino you get 275 (275 machine cycles). That means it takes the Arduino 17 microseconds to complete the loop when there is no delay.  Looking at the code it is hard to believe 275 machines cycles are required to prepare the next unsigned long integer to be shifted out then clock it out, but I do not know how many of those are used up by the ShiftOut() library function that is called three tiems to shift out all 24 bits.




SourceCode on GitHub

Sunday, November 8, 2015

Serial to Parallel Shifting-Out with a 74HC595

 Using the 74HC595 to control 8 leds (outputs) without giving up 8 ports on the arduino uno. Three outputs from the arduino are used to shift the data out in serial to the 74HC595 were it is then parceled out to each of its individual pins. You can link multiple registers together to extend your output even more, without giving up any more pins on the arduino.
Note: The shift register is not what gives the appearance of the led going back and foth...ie shifting. All the shifting happens prior to the output states changing. The led appears to be shifting because it is in a loop writing int 1, 2, 4, 8, 16, 32, 64, 128, 64, 32, 16, 8, 4, and 2.
Next, I will be connecting four of the  74HC595s together to experiment with controlling 32 outputs with 3 pins from the arduino.  Then modify the circuit to control four seven segment leds with 3 pins.  Why do this instead of using the low cost I2C interface?  Speed.  I2C runs at 100k where these shift registers can be clocked as fast as for for loop that shifts the data out, which is well over 1mb/sec.



This is the code used in the video above.  Pin out for the 74HC595 along with a short tutorial by Simon Monk can be found here.

Source Code Here:

Wednesday, November 4, 2015

Controlling an RGB LED with PWM

This is an example from the Arduino Workshop.  You can breadboard the circuit or use a squid


Squid connected directly to Arduino


RGB LED Pinout


Sample code from Arduino Workshop that will demonstrate the RGB Led.



Here it is in Action




Tuesday, November 3, 2015

Playing Music With Remote Control

This was the first experiment I did with Ken Shirrif's Infrared Remote Control Library for the Arduino.

The circuit uses a TSOP382 IR photo sensor to receive the codes from the Clarion remote controller I had lying around.  Once the code is received the program then decides which tone to play.  In this example I have 8 tones set up, middle c through middle b.  For added fun and visual effects I turn on a led for each of the notes as they are played.

Here is a short video of a few notes being played on the Arduino.  Below the video is the code along with some instructions on how to modify the library so it will work with the tone() function.



If you try to use this you will need to install the Arduino library written by Ken Shirrif.  You will also need to modify the library so that it uses TIMER1 instead of TIMER2 because TIMER2 is used by the tone() function.

Technology librarian Trey Ford explains how you modify the library to use TIMER1

  1. First, go to Libraries\Documents\Arduino\libraries\IRremote , the files for the library would be there.
  2. In IRremoteInt.h, at line 194 we have this

    //Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
    #else
      //#define IR_USE_TIMER1 // tx = pin 9
      #define IR_USE_TIMER2 // tx = pin 3
    #endif
  3. We’d need to uncomment the IR_USE_TIMER1 line and comment the IR_USE_TIMER2 line like this:
        // Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
        #else
                #define IR_USE_TIMER1 // tx = pin 9
               //#define IR_USE_TIMER2 // tx = pin 3
        #endif


Now if your using codebender you will need to upload the modified version of Ken Shirrif's library to your personal libraries so that when compiling it will user your modified version rather than the default version that is allready registered with codebender.

Here is the code:


Monday, November 2, 2015

Remote Controlling Arduino Robot Shield

Received my board of education arduuino robot shield last Friday and the first thing I wanted to try after assembling it was to control it with an IR remote using Ken Shirrifs IR Library.

The motors on the robot are 360 degree servos that are controlled by sending them a digital pulse ranging in duration from 1300 to 1700 microseconds every 20milliseconds.  The width of the pulse determines the speed and direction they rotate.  1500 would be no motion at all, 1300 full speed counter clockwise and 1700 full speed counter clockwise.  While this is modifying the width of the pulse it is not the same as the PWM functions found in the Arduino library.

When polling for commands from the IR receiver I found that that this particular remote requires me give it at least 175 ms before attempting to read its next transmission.   That, combined with the IR remote being single channel makes for a choppy RC because within 200 ms the servos have already repeated the last command 10 times.

Oh and if you are wondering why no beeping from the Robot it is because the tone function is unable to access TIMER2 because it is being used by the IR Library   The servo library uses TIMER1.

Here is a short video




Here is the Code: