Eleven + RELAY8 = geek binary display

The "Eleven" is our Uno-equivalent Arduino-compatible board, but with a number of improvements including prototyping area, a mini-USB connector, LEDs mounted near the edge, and the D13 LED isolated using a FET. [Product page]
Post Reply
dudleydo
Posts: 13
Joined: Fri Dec 30, 2011 4:57 am

Eleven + RELAY8 = geek binary display

Post by dudleydo » Sun Sep 02, 2012 2:06 pm

Just a quick bit of chopped up code to make a binary counter/clock of sorts, using an Eleven and a RELAY8 board.

Takes about 8 minutes, 30 seconds to run one loop :)
#include "Wire.h"
#define I2C_ADDR  0x20  // 0x20 is the address with all jumpers removed
int stepval;

void setup()
{

  Wire.begin(); // Wake up I2C bus

  // Set addressing style
  Wire.beginTransmission(I2C_ADDR);
  Wire.write(0x12);
  Wire.write(0x20); // use table 1.4 addressing
  Wire.endTransmission();

  // Set I/O bank A to outputs
  Wire.beginTransmission(I2C_ADDR);
  Wire.write(0x00); // IODIRA register
  Wire.write(0x00); // Set all of bank A to outputs
  Wire.endTransmission();
  sendValueToLatch(0);   // workaround to make sure all are off at start
}

void loop()
{
for (stepval = 0; stepval < 256; stepval++)
{
  sendValueToLatch(stepval);
  delay(1000);
}
for (stepval = 255; stepval >= 0; stepval--)
{
  sendValueToLatch(stepval);
  delay(1000);
}
}

void sendValueToLatch(int latchValue)
{
  Wire.beginTransmission(I2C_ADDR);
  Wire.write(0x12); // Select GPIOA
  Wire.write(latchValue); // Send value to bank A
  Wire.endTransmission();
}
Binary sketch size: 2,718 bytes (of a 32,256 byte maximum)

rebboc
Posts: 7
Joined: Tue Sep 11, 2012 1:07 pm
Location: Wollongong

Re: Eleven + RELAY8 = geek binary display

Post by rebboc » Tue Sep 11, 2012 1:43 pm

This works fine using an Eleven as the processor, however, the example in the Relay 8 quick start guide does not work with an Eleven, but will work with a UNO. Any idea why?

rebboc
Posts: 7
Joined: Tue Sep 11, 2012 1:07 pm
Location: Wollongong

Re: Eleven + RELAY8 = geek binary display

Post by rebboc » Mon Sep 17, 2012 8:54 pm

Haven't had any other problems, but haven't used it much - it's only about ten days old. Next time I get a chance to play, I will go through the code line by line and make sure there is nothing untoward there. Also, will check with oscilloscope to see where the output is getting lost. The fact that the geek clock works seems to indicate that it is unlikely to be a hardware problem.

Post Reply