---

Friday, November 23, 2012

Using .NET Gadgeteer Modules with Arduino - Relay

The .NET Gadgeteer system has spawned a wide range of low cost and useful modules form places like GHI Electronics and Seedstudio.

I have a load of Gadgeteer modules, sitting in a cupboard, so I thought it would be good to see how hard it would be to use them with an Arduino. I decided to start with a nice easy one, this relay module from Seedstudio. It has four relays, each with an indicator LED.

The Gadgeteer modules are all connected by 10 way ribbon cable connectors. So clearly, the first thing we need is to make a lead that we can use to connect the module to breadboard.

I cut a lead in half and stripped the 10 wires from the half of the lead with the connector notch to the left. This turned out to be pretty easy. I was rather expecting it to go wrong and the leads end up all sorts of different lengths - but the wires stripped really easily.

I found that using a craft knife to separate the leads helped.
I then tinned the stripped wires and soldered them to a length of 10 pin header stuck into breadboard to stop it moving.

There we go, a lead that we can use with any Gadgeteer module.

The Gadgeteer system has many different types of pinout for these connectors. The relay module uses a type-Y socket, which is a general purpose IO arrangement. There are other types for serial, USB, I2C, analog and all sorts. They all use the same connectors, but have different pinouts.

You can find full details of all the pinout options here.

The pinouts for the type-Y are as below:



Here is a section of the Eagle schematic for the relay module (Open Source).

Although Gadgeteer modules are often 3.3V, this design will have no problem using 5V levels, so all looks promising. The control pins for the relays are connected to Gadgeteer pins 3, 4, 5 and 6.

The schematic shows the relay coils being supplied from 5V (pin 2), but testing with a multimeter, I found that the 'top' connection of the relay coil was actually connected to pin 1 (3.3V). I don't really understand this discrepancy, but no problem, in this case we can supply 5V from the Arduino to pin 1 of the module. That would be a bad thing to do for most types of Gadgeteer module - be Warned!

Here is the wired up breadboard:



  • Pin 1 of the Gadgeteer connector goes to Arduino 5V
  • Pin 10 of the Gadgeteer connector goes to Arduino GND
  • Pins 3, 4, 5 and 6 of the Gadgeteer connector goes to Arduino D2, D3, D4 and D5 respectively
Here is a little test sketch that lets you turn each Relay on and off using the Serial Monitor.




// Gadgeteer Relay Board

int relayPins[] = {2, 3, 4, 5};

void setup()
{
  for (int i = 0; i < 4; i++)
  {
    pinMode(relayPins[i], OUTPUT);
  }
  Serial.begin(9600);
  while (!Serial);
  Serial.println("A, B, C, D to turn relay on");
  Serial.println("a, b, c, d to turn relay off");
}

void loop()
{
  if (Serial.available())
  {
    char ch = Serial.read();
    if (ch >= 'A' && ch <= 'D')
    {
      digitalWrite(relayPins[ch - 'A'], HIGH);
    }
    if (ch >= 'a' && ch <= 'd')
    {
      digitalWrite(relayPins[ch - 'a'], LOW);
    } 
  }
}



Conclusion
Now that I have a lead, I need to think about which Gadgeteer module to try next!

Perhaps one of the I2C modules?

                        
About the Author
These are my books. Click on the image below to find out more about them.




                                                                 

Saturday, November 17, 2012

Review: Adafruit 16x2 OLED Display

If you are an Arduino user, you may well have used a 16x2 LCD display. These displays require a pot to set the contrast. The Adafruit 16x2 OLED display does away with the need for this pot.

In all other ways it works just like an LCD 16x2 display and uses the standard LiquidCrystal library.

Its not that obvious from the photo above, but this display is lovely! The background is jet black under most lighting and the LED emissive display much clearer than the LCD equivalents.

It is not a cheap option, but for that special project, I Highly recommend this display.

Here's the code, straight from the Example sketch - with a few pin changes:

/*
  LiquidCrystal Library - Hello World
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the 
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 This sketch prints "Hello World!" to the LCD
 and shows the time.
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

About the Author
These are my books. Click on the image below to find out more about them.


Sunday, November 4, 2012

Laser cut 'Recording Sign'

Thanks once again to FabLabMcr I have used the laser cutter to make a 'Recording' light for my son's studio.


It was really easy to make. Its basically a red / clear acrylic sandwich with paper in the middle as the filling. The letters are in a stencil font that is cut from the red layer.

This is then screwed to the front of a wooden frame, that contains a main lamp holder with a 15W compact fluorescent in it. Holes are drilled into the top to let the heat escape.



Here are the PDF files for laser cutting.

Clear Layer.

About the Author
These are my books. Click on the image below to find out more about them.