Ontrak ADU208 – Mk1

Ontrak ADU208

Ontrak ADU208 01 Mk01

Ontrak ADU208 01 Mk02

Ontrak ADU208 01 Mk03

ADU208 USB Relay I/O Interface ( Dimensions, 5.1″ X 2.8 X 1.0″ )

The ADU208 USB Relay I/O Interface allows control of 8 relay contact outputs, 8 contact or TTL inputs, and 8 event counters via a USB port. The ADU208 can effectively convert a standard PC to a powerful PLC ( programmable logic controller ). High quality PA-Series relays from Aromat offer superior performance. This low-cost serial relay contact interface is easy to use with VB, VB.NET, and Visual C++ via standard HID drivers included with Windows 98,2000,XP. A mini-driver ( DLL )* is also provided allowing control using standard ASCII commands using familiar readfile , writefile commands. The ADU208 includes a 10′ USB cable and is available as a PCB or in an enclosure with several mounting options.

Key Benefits, ADU208 USB Relay I/O Interface

Provides a standard PC with PLC ( programmable logic controller ) functions.
Low-cost .
Bus Powered, No external power supply required.
8, N. O. relay contact outputs rated 5.0A @ 120VAC, 5.0A @ 30VDC
CSA/UL Approved, CE Marked
High quality Aromat PA-series relays offer superior performance.
8 Digital inputs suitable for contact or TTL Input , also accept up to 24VDC
Inputs feature optical isolation to 3500V ( 500V channel to channel )
Programmable watchdog functions.
Bi-colour LED status indicator.
Self-resetting, fused 5V output
High quality cage-clamp type terminal blocks.
Uses standard HID drivers included with Windows 98SE,2000,XP
Mini-driver ( DLL ) provided for use with VB,VC, LabVIEW and TestPoint
Programming examples and sample code included for VB, Visual C++
Eight, 16-bit event counters
Programmable debounce setting for event counters.
No power supply required.
Meets IEC61000-4-2 ESD protection for USB port.
Available in enclosure or as PCB only.

Don Luc

Project #3 – LCD Shield – Mk5

LCD Shield Mk5.01

LCD Shield Mk5.02

LCD Shield Mk5.03

LCD Shield Mk5.04

LCD Shield Mk5.05

LCD Shield Mk5.06

LCDShieldMk5.1.ino

// ***** Don Luc *****
// Software Version Information
// 5.1

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <SPI.h>
#include <RTClib.h>
#include <RTC_DS3231.h>
#include <OneWire.h> 

RTC_DS3231 RTC;

#define SQW_FREQ DS3231_SQW_FREQ_1024     //0b00001000   1024Hz

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

int yy = 0;
uint8_t momentaryButton = 0;

// Chorno
boolean isChorno = true;
boolean isChor = false;
char datastr[100];
int zz = 0;
// LDR (light dependent resistor)
int LDR_Pin = A0;
int LDRReading = 0;
String LDR = "";
// Temperature chip i/o
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
OneWire ds(DS18S20_Pin);  // on digital pin 2
float temperature = 0;
String tempZ = "";
// Potentiometer
int potPin = A2;    // select the input pin for the potentiometer
int ledPin = 4;   // select the pin for the LED
boolean isVal = false;
int potPot = 0;
String cap = "";

void loop() {

  RGBLCDShield.clear();
    
  // ChronoDot
  // set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  timeChrono();
  // LDR (light dependent resistor)
  timeLDR();
  // Temperature chip i/o
  temperatu();
  // Potentiometer
  getPotentio();
    
  momentaryButton = RGBLCDShield.readButtons();

  // set the cursor to column 0, line 0
  RGBLCDShield.setCursor(0,0);

  switch ( yy ) {
    case 1:
      // LDR (light dependent resistor)
      isLDR();
      break;
    case 2:
      // Temperature chip i/o
      isTe();
      break;
    case 3:
      // Potentiometer
      isCap();
      break;
    case 4:
      // Yellow
      RGBLCDShield.print("YELLOW - RIGHT");
      break;
    case 5:
      // OFF
      RGBLCDShield.print("OFF");
      break;
    default: 
      yy = 0;
      RGBLCDShield.print("Don Luc!!!");
   }
   
  if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      isChorno = true;
      yy = 1;
      // LDR (light dependent resistor)
      RGBLCDShield.setBacklight(GREEN);
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      isChorno = true;
      yy = 2;
      // Temperature chip i/o
      RGBLCDShield.setBacklight(RED);
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      isChorno = true;
      yy =3;
      // Potentiometer
      RGBLCDShield.setBacklight(BLUE);
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {
      isChorno = true;
      yy = 4;
      //RGBLCDShield.print("YELLOW - RIGHT");
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {
      isChorno = false;
      yy = 5;
      //RGBLCDShield.print("OFF");
      RGBLCDShield.setBacklight(OFF);
    }
    
  }
  
  delay(5000);
  
}

setup.ino

void setup() {    
   
  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(VIOLET);
  
  // ChronoDot
  setupChrono();
  
  // Pot
  pinMode(ledPin, OUTPUT);
    
}

ChronoDot.ino

void setupChrono() {

  RTC.begin();
  
  DateTime now = RTC.now();
  DateTime compiled = DateTime(__DATE__, __TIME__);
  RTC.getControlRegisterData( datastr[0] );  
   
}

void timeChrono() {
 
    DateTime now = RTC.now();
    DateTime isNow (now.unixtime() + 5572 * 86400L + 26980);

    if ( isChorno == true )
    {
      if ( isChor == false ) 
        {          
          isChor = true;
          RGBLCDShield.print(isNow.year(), DEC);
          RGBLCDShield.print('/');
          RGBLCDShield.print(isNow.month(), DEC);
          RGBLCDShield.print('/');
          RGBLCDShield.print(isNow.day(), DEC);
          RGBLCDShield.print(' ');
          RGBLCDShield.print(' ');
        }
        else if ( isChor == true )
        {
          isChor = false;
          RGBLCDShield.print(isNow.hour(), DEC);
          RGBLCDShield.print(':');
          RGBLCDShield.print(isNow.minute(), DEC);
          RGBLCDShield.print(':');
          RGBLCDShield.print(isNow.second(), DEC);
          RGBLCDShield.print(' ');
          RGBLCDShield.print(' ');
        }
    }
    
}

getLDR.ino

void timeLDR() {
  
  // LDR
  LDRReading = analogRead(LDR_Pin);
 
}

void isLDR() {
  
  LDR = "LDR: ";
  LDR.concat(LDRReading); 
  // LDR (light dependent resistor)
  RGBLCDShield.print( LDR ); 
  
} 

getPot.ino

void getPotentio() {
  
    if ( isVal == false ) 
    {
       isVal = true;
       digitalWrite(ledPin, HIGH);  // turn the ledPin on
    }
    else if ( isVal == true )
    {
       isVal = false;
       digitalWrite(ledPin, LOW);  // turn the ledPin off
    }       
    potPot = analogRead(potPin);    // read the value from the sensor
  
}

void isCap(){
  
    cap = "Pot: ";
    cap.concat(potPot);
    RGBLCDShield.print( cap );

}

getTemperature.ino

float getTemp() {
  
  //returns the temperature from one DS18S20 in DEG Celsius
  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
      //no more sensors on chain, reset search
      ds.reset_search();
      return -1001;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      return -1002;
  }

  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      return -1003;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE); // Read Scratchpad

  
  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }
  
  ds.reset_search();
  
  byte MSB = data[1];
  byte LSB = data[0];

  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
  
  return TemperatureSum;

}

void temperatu(){
  
  temperature = getTemp();
 
}

void isTe() {
  
  tempZ = "Temp: ";
  tempZ.concat(temperature);
  tempZ.concat("C");
  RGBLCDShield.print( tempZ );
  
}

Don Luc

Project #3 – LCD Shield – Mk4

LCD Shield Mk4.01

LCD Shield Mk4.02

LCD Shield Mk4.03

LCD Shield Mk4.04

LCD Shield Mk4.05

LCD Shield Mk4.06

LCD Shield Mk4.07

LCD Shield Mk4.08

LCD Shield Mk4.09

LCD Shield Mk4.10

LCD Shield Mk4.11

LCD Shield Mk4.12

LCD Shield Mk4.13

LCD Shield Mk4.14

LCD Shield Mk4.15

LCD Shield Mk4.16

LCD Shield Mk4.17

LCD Shield Mk4.18

LCD Shield Mk4.19

LCD Shield Mk4.20

LCD Shield Mk4.21

LCD Shield Mk4.22

1 X Mini Photocell

1 X Resistor 10k Ohm

1 X One Wire Digital Temperature Sensor – DS18B20

1 X Resistor 4.7k Ohm

1 X Trimpot 10K with Knob

1 X Resistor 1.65k Ohm

1 X 3MM Low Current Red LED

14 X Jumper Wires Premium 3″ M/M

1 X Project #3 – LED Shield – Mk3

LCDShieldMk4.3.ino

// ***** Don Luc *****
// Software Version Information
// 4.3

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <SPI.h>
#include <RTClib.h>
#include <RTC_DS3231.h>
#include <OneWire.h> 

RTC_DS3231 RTC;

#define SQW_FREQ DS3231_SQW_FREQ_1024     //0b00001000   1024Hz

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

// Chorno
boolean isChorno = false;
char datastr[100];
// LDR (light dependent resistor)
int LDR_Pin = A0;
String LDR = "";
// Temperature chip i/o
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
OneWire ds(DS18S20_Pin);  // on digital pin 2
String tempZ = "";
// Potentiometer
int potPin = A2;    // select the input pin for the potentiometer
int ledPin = 4;   // select the pin for the LED
boolean isVal = false;
int potPot = 0;
String cap = "";

void loop() {

  // timeChrono();
  timeChrono();
  
  uint8_t momentaryButton = RGBLCDShield.readButtons();

  if ( momentaryButton ) {

    RGBLCDShield.clear();
  
    RGBLCDShield.setCursor(0,0);
    
    if ( momentaryButton & BUTTON_UP ) {
      timeLDR();
      RGBLCDShield.print( LDR );
      RGBLCDShield.setBacklight(GREEN);
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      temperatu();
      RGBLCDShield.print( tempZ );
      RGBLCDShield.setBacklight(RED);
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      getPotentio();
      RGBLCDShield.print( cap );
      RGBLCDShield.setBacklight(BLUE);
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {
      RGBLCDShield.print("YELLOW - RIGHT");
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {
      RGBLCDShield.print("OFF");
      RGBLCDShield.setBacklight(OFF);
    }
        
  }
  
  delay(3000);
  
}

setup.ino

void setup() {    
   
  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.print("Don Luc!!!");
  RGBLCDShield.setBacklight(VIOLET);
  
  // ChronoDot
  setupChrono();
  
  // Pot
  pinMode(ledPin, OUTPUT);
   
}

ChronoDot.ino

void setupChrono() {

  RTC.begin();
  
  DateTime now = RTC.now();
  DateTime compiled = DateTime(__DATE__, __TIME__);
  RTC.getControlRegisterData( datastr[0] );  
 
}

void timeChrono() {
 
    DateTime now = RTC.now();
    DateTime isNow (now.unixtime() + 5572 * 86400L + 26980);
    
    // set the cursor to column 0, line 1
    RGBLCDShield.setCursor(0, 1);
    
    if ( isChorno == false ) 
    {
      isChorno = true;
      RGBLCDShield.print(isNow.year(), DEC);
      RGBLCDShield.print('/');
      RGBLCDShield.print(isNow.month(), DEC);
      RGBLCDShield.print('/');
      RGBLCDShield.print(isNow.day(), DEC);
      RGBLCDShield.print(' ');
      RGBLCDShield.print(' ');
    }
    else if ( isChorno == true )
    {
      isChorno = false;
      RGBLCDShield.print(isNow.hour(), DEC);
      RGBLCDShield.print(':');
      RGBLCDShield.print(isNow.minute(), DEC);
      RGBLCDShield.print(':');
      RGBLCDShield.print(isNow.second(), DEC);
      RGBLCDShield.print(' ');
      RGBLCDShield.print(' ');
    }

}

getLDR.ino

void timeLDR() {
  
  // LDR
  int LDRReading = analogRead(LDR_Pin);
  LDR = "LDR: ";
  LDR.concat(LDRReading); 

}

getPot.ino

void getPotentio() {
  
    if ( isVal == false ) 
    {
       isVal = true;
       digitalWrite(ledPin, HIGH);  // turn the ledPin on
    }
    else if ( isVal == true )
    {
       isVal = false;
       digitalWrite(ledPin, LOW);  // turn the ledPin off
    }       
    potPot = analogRead(potPin);    // read the value from the sensor
    cap = "Pot: ";
    cap.concat(potPot);

}

getTemperature.ino

float getTemp() {
  
  //returns the temperature from one DS18S20 in DEG Celsius
  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
      //no more sensors on chain, reset search
      ds.reset_search();
      return -1001;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      return -1002;
  }

  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      return -1003;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE); // Read Scratchpad

  
  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }
  
  ds.reset_search();
  
  byte MSB = data[1];
  byte LSB = data[0];

  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
  
  return TemperatureSum;

}

void temperatu(){
  
  float temperature = getTemp();
  tempZ = "Temp: ";
  tempZ.concat(temperature);
  tempZ.concat("C");

}

Don Luc

Project #3 – LCD Shield – Mk3

LCD Shield Mk3.01

LCD Shield Mk3.02

LCD Shield Mk3.03

2 X Jumper Wires Premium 3″ M/M

1 X Project #3 – LED Shield – Mk2

LCDShieldMk3.0.ino

// ***** Don Luc *****
// Software Version Information
// 3.0

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <SPI.h>
#include <RTClib.h>
#include <RTC_DS3231.h>

RTC_DS3231 RTC;

#define SQW_FREQ DS3231_SQW_FREQ_1024     //0b00001000   1024Hz

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

boolean isChorno = false;

char datastr[100];

void loop() {
   
  // timeChrono();
  timeChrono();

  uint8_t momentaryButton = RGBLCDShield.readButtons();

  if ( momentaryButton ) {

    RGBLCDShield.clear();
  
    RGBLCDShield.setCursor(0,0);
    
    if ( momentaryButton & BUTTON_UP ) {
      RGBLCDShield.print("GREEN - UP");
      RGBLCDShield.setBacklight(GREEN);
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      RGBLCDShield.print("RED - DOWN");
      RGBLCDShield.setBacklight(RED);
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      RGBLCDShield.print("BLUE - LEFT");
      RGBLCDShield.setBacklight(BLUE);
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {
      RGBLCDShield.print("YELLOW - RIGHT");
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {
      RGBLCDShield.print("OFF");
      RGBLCDShield.setBacklight(OFF);
    }
        
  }
  
  delay(3000);
  
}

setup.ino

void setup() {

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.print("Don Luc!!!");
  RGBLCDShield.setBacklight(VIOLET);
  
  // ChronoDot
  setupChrono();    
  
}

ChronoDot.ino

void setupChrono() {

  RTC.begin();
  
  DateTime now = RTC.now();
  DateTime compiled = DateTime(__DATE__, __TIME__);
  RTC.getControlRegisterData( datastr[0] );    

}

void timeChrono() {

    DateTime now = RTC.now();
    DateTime isNow (now.unixtime() + 5572 * 86400L + 26980);
    
    // set the cursor to column 0, line 1
    RGBLCDShield.setCursor(0, 1);
 
    if ( isChorno == false ) 
    {
      isChorno = true;
      RGBLCDShield.print(isNow.year(), DEC);
      RGBLCDShield.print('/');
      RGBLCDShield.print(isNow.month(), DEC);
      RGBLCDShield.print('/');
      RGBLCDShield.print(isNow.day(), DEC);
      RGBLCDShield.print(' ');
      RGBLCDShield.print(' ');
    }
    else if ( isChorno == true )
    {
      isChorno = false;
      RGBLCDShield.print(isNow.hour(), DEC);
      RGBLCDShield.print(':');
      RGBLCDShield.print(isNow.minute(), DEC);
      RGBLCDShield.print(':');
      RGBLCDShield.print(isNow.second(), DEC);
      RGBLCDShield.print(' ');
      RGBLCDShield.print(' ');
    }
  
}

Don Luc

Project #3 – LCD Shield – Mk2

LCD Shield Mk2.01

LCD Shield Mk2.02

LCD Shield Mk2.03

LCD Shield Mk2.04

LCD Shield Mk2.05

LCD Shield Mk2.06

LCD Shield Mk2.07

LCD Shield Mk2.08

LCD Shield Mk2.09

LCD Shield Mk2.10

LCD Shield Mk2.11

LCD Shield Mk2.12

LCD Shield Mk2.13

LCD Shield Mk2.14

LCD Shield Mk2.15

LCD Shield Mk2.16

LCD Shield Mk2.17

LCD Shield Mk2.18

LCD Shield Mk2.19

LCD Shield Mk2.20

LCD Shield Mk2.21

LCD Shield Mk2.22

LCD Shield Mk2.23

LCD Shield Mk2.24

LCD Shield Mk2.25

1 X ChronoDot

1 X ProtoScrewShield

1 X Breadboard

4 X Jumper Wires Premium 3″ M/M

1 X CR1632

1 X Project #3 – LED Shield – Mk1

LCDShieldMk2.2.ino

// ***** Don Luc *****
// Software Version Information
// 2.2

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

uint8_t i = 0;

void loop() {
  
  timeChrono();

  uint8_t momentaryButton = RGBLCDShield.readButtons();

  if ( momentaryButton ) {
    
    RGBLCDShield.clear();
    RGBLCDShield.setCursor(0,0);
    
    if ( momentaryButton & BUTTON_UP ) {
      RGBLCDShield.print("GREEN - UP ");
      RGBLCDShield.setBacklight(GREEN);
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      RGBLCDShield.print("RED - DOWN ");
      RGBLCDShield.setBacklight(RED);
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      RGBLCDShield.print("BLUE - LEFT ");
      RGBLCDShield.setBacklight(BLUE);
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {
      RGBLCDShield.print("YELLOW - RIGHT ");
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {
      RGBLCDShield.print("OFF ");
      RGBLCDShield.setBacklight(OFF);
    }
        
  }
  
  delay(1000);
  
}

setup.ino

void setup() {

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.print("Don Luc!!!");
  RGBLCDShield.setBacklight(VIOLET);
  
  // ChronoDot
  setupChrono();    
  
}

ChronoDot.ino

void setupChrono() {

  // clear /EOSC bit
  // Sometimes necessary to ensure that the clock
  // keeps running on just battery power. 
  Wire.beginTransmission(0x68); // address DS3231
  Wire.write(0x0E); // select register
  Wire.write(0b00011100); // write register bitmap, bit 7 is /EOSC
  Wire.endTransmission();  

}

void timeChrono() {

  // set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  
   // send request to receive data starting at register 0
  Wire.beginTransmission(0x68); // 0x68 is DS3231 device address
  Wire.write((byte)0); // start at register 0
  Wire.endTransmission();
  Wire.requestFrom(0x68, 3); // request three bytes (seconds, minutes, hours)
 
  while(Wire.available())
  { 

    int seconds = Wire.read(); // get seconds
    int minutes = Wire.read(); // get minutes
    int hours = Wire.read();   // get hours
 
    seconds = (((seconds & 0b11110000)>>4)*10 + (seconds & 0b00001111)); // convert BCD to decimal
    minutes = (((minutes & 0b11110000)>>4)*10 + (minutes & 0b00001111)); // convert BCD to decimal
    hours = (((hours & 0b00100000)>>5)*20 + ((hours & 0b00010000)>>4)*10 + (hours & 0b00001111)); // convert BCD to decimal (assume 24 hour mode)
 
    // print the number of seconds since reset:
    RGBLCDShield.print(hours);
    RGBLCDShield.print(":");
    RGBLCDShield.print(minutes);
    RGBLCDShield.print(":");
    RGBLCDShield.print(seconds);

  }
  
}

Don Luc

Project #3 – LCD Shield – Mk1

LCDShield1

LCDShield2

LCDShield3

LCDShield4

LCDShield5

LCDShield6

LCDShield7

LCDShield8

LCDShield9

LCDShield10

LCDShield11

LCDShield12

LCDShield13

LCDShield14

LCDShield15

LCDShield16

LCDShield17

LCDShield18

LCDShield19

LCDShield20

1 X Arduino UNO Rev3

1 X Adafruit I2C Controlled + Keypad Shield Kit for 16×2 LCD

1 X RGB backlight positive LCD 16×2 + extras – black on RGB

LCDShieldMk1.3.ino

// ***** Don Luc *****
// Software Version Information
// 1.3

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

uint8_t i = 0;

void loop() {
  
  // set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // print the number of seconds since reset:
  RGBLCDShield.print(millis() / 1000);

  uint8_t momentaryButton = RGBLCDShield.readButtons();

  if ( momentaryButton ) {
    
    RGBLCDShield.clear();
    RGBLCDShield.setCursor(0,0);
    
    if ( momentaryButton & BUTTON_UP ) {
      RGBLCDShield.print("GREEN - UP ");
      RGBLCDShield.setBacklight(GREEN);
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      RGBLCDShield.print("RED - DOWN ");
      RGBLCDShield.setBacklight(RED);
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      RGBLCDShield.print("BLUE - LEFT ");
      RGBLCDShield.setBacklight(BLUE);
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {
      RGBLCDShield.print("YELLOW - RIGHT ");
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {
      RGBLCDShield.print("OFF ");
      RGBLCDShield.setBacklight(OFF);
    }
    
  }
  
}

setup.ino

void setup() {
    
  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);

  // We track how long it takes since
  int time = millis();
  RGBLCDShield.print("Don Luc!!!");
  time = millis() - time;
  RGBLCDShield.setBacklight(VIOLET);
}

Don Luc

Fun with browsers and WordPress

Apr 30, 2010 @ 20:40

It has been one of those days. Somebody reported to me last night that the theme of our <a href=”http://www.igourmand.com/eatdrink/”>food and wine blog</a> did not display the first photo of any page correctly. The first image appeared after a huge space. The problem only happened with Internet Explorer and everything was fine with Firefox. Thus became the quest early this morning at 8am and I started tracking the problem.

I first thought that it was some “Div” problem as the theme used was one that I had made over 5 years ago. I recently rewrote it to change the look and then I rewrote it again last week to bring it into line with the current WordPress theme architecture. I had yet to polish it and finish formatting it and commenting it properly, so my logical thought was it was just some error in one of the PHP files of the theme. I even remembered checking it with various browsers just last week to make sure there was not such a problem, but since I have been doing small incremental update maybe some little error slipped in and I did not catch it.

I first checked the source code in the browser to see if I could find something wrong there. I used a few automated HTML formatter and the results were dismal. If somebody has a good HTML formatter that actually works to recommend, please let me know.

I ended up formatting everything by hand and after reviewing the code found out that there was absolutely nothing obviously wrong with it, and nothing that would explain the discrepancy between Firefox and IE. I had a hunch that the problem might be with the sidebar code, so I disabled it and low and behold the huge space before the first image on a page disappeared. Thus my hunch was right.

I then re-enabled each section of the sidebar one after another until the problem reappeared and finally found that the problem was with the image links I added a few days ago in the sidebar. There is absolutely no reason that IE should behave this way, except that it does not interpret the CSS properly. There is plenty of space for both the sidebar image links and the image in the post, and even if I resized the image in the post to a smaller size the problem continued.

I then starting fine-tuning the CSS and with just a few minor changes of around 15 pixels in one section everything popped back together as it should. I guess that IE is just very bad at properly following the CSS and placing elements on the screen.

Once that was done I decided that since I was in the middle of doing a lot of things with the theme, I should finish it properly. I spent the rest of the day properly formatting the code, changing deprecated WordPress functions to their new versions, profusely commenting the theme so the next time I need to modify things I can quickly find what I am looking for, doing some minor cosmetic changes to the theme, and generally improved its function and look. I still want to spend a bit of time beautifying things, but now it will be a much simpler job after the work that was done today.

What started as what I thought would be a simple job finding a faulty line of code, ended up a day of detective work. The nice thing is that I learned a lot dissecting the more recent template format of WordPress as I had not digged in its depths since version 1.5. It is much more flexible and powerful now and I will go to bed much less stupid tonight after a great day learning new things about the inner works of WordPress. I’m just glad that the work was for myself as I would not have like to explain the reason to justify a full day a work simply to move a picture up in a blog to a client.

Don Luc