USB/Ethernet Relay Card with 8 relays


Arduino compatible web server based relay card which also can be used with USB connection. No special soldering skills required. Easy to program with popular ENC28J60 Ethernet controller. All Arduino Ethernet libraries are compatible e.g. this ENC28J60 library. Only one +5V USB power supply needed. All relais can be controlled individually. Relais can drive 5A load from 230V.

Board uses FTDI USB i.c. Arduino bootloader natively supports USB and virtual serial port. Device is programmable via USB port with Arduino IDE or similar programs.

All parts can buy from Only exception is ethernet connector. It must include transformers and filter elements.


Multipurpose 7-segment Display System (Part 1.)

Here is my latest invention. Arduino compatible multipurpose 7-segment display driver. It can be used in many places. To mention few it can be used in gas station price display, score board display in sport and clock or temperature view on store roof to catch eye.

Controlling format can be any and connection is USB virtual serial port. Power supply needs to supply +12V and +5V. Amperage is in accordance with display count. One display draws max. about 240mA from +12V line when all segments are on.

Main board is populated with all components. Slave modules does not need the atMega328P-PU chip and its related components. Board is connected directly on back of a display element. Display height must be 100mm and connectors distance 106.68-107.00mm.

Data line from last display must connect to the feedback line. Then it is programmatically possible to count displays and it is not necessary to manually import display count to microcontroller. Displays are counted from right to left.

Here is schematics for revision 3.


All components except the display can buy from

Display, KW1-4003ASA, any similar will go and also with reversed polarity. Common pins 1,8 or 3,8. Select with J8.

Unregulated AC/DC power supply can be used with 12V and 5V voltage regulation kits from Tayda:

One 12V regulator is giving enough power for about four displays. 5V power consumption is much less and not need to worry about it. One 5V regulator is enough for most users.

Cable between modules contains 7 wires:

Last display data line and feedback line connection can be made with mini jumper.

Arduino compatible

On final product Arduino bootloader is preinstalled on to atMega328P-PU chip before installing it to board. First prototype works with Arduino Nano and has one display. Below is program code that supports multiple displays.


/* Multipurpose 7-segment Display Driver
 * Juvar's Electronics Corner
 * Juvar
 * Juha-Pekka Varjonen
 * version 1.4
 * Master unit is connected to last display in row
 * Leftmost display data output is connected to feedback line
 * bug in C language:
 * array[0] = cannot write
 * array is zero indexed but cannot save data in to zero position

#define SER 2
#define FB 3
#define OE 4
#define CLK 5

int dispCount;
int pos = 1;

 *   _A_  
 * F|   |B
 *  |_G_|
 *  |   |
 * E|___|C
 *    D

byte num[12] = {
  0b01111110, /* 0 */
  0b00011000, /* 1 */
  0b01101101, /* 2 */
  0b00111101, /* 3 */
  0b00011011, /* 4 */
  0b00110111, /* 5 */
  0b01110111, /* 6 */
  0b00011100, /* 7 */
  0b01111111, /* 8 */
  0b00111111, /* 9 */
  0b00000000  /* space */
byte dataArr[20];

void setup() {
  // make the pins outputs
  pinMode(SER, OUTPUT); // serial data
  pinMode(OE, OUTPUT); // output enable
  pinMode(CLK, OUTPUT); // clock pulse
  // disable display output
  digitalWrite(OE, HIGH);
  // initialize serial

  // count displays
  int i = 0;
  byte temp;
  //set data
  digitalWrite(SER, HIGH);
  do {
    // toggle clock pulse
    digitalWrite(CLK, HIGH);
    digitalWrite(CLK, LOW);
    bitWrite(temp, 0, digitalRead(FB));
    temp = temp << 1;
  } while (temp != 0b11111110);
  dispCount = (i+1)/8;
  // clear data
  digitalWrite(SER, LOW);

void loop() {
  // if there's any serial available, read it
  while (Serial.available() > 0) {
    // read the incoming byte
    char data =;
    // if any numbers
    if (data >= 48 && data <= 57) dataArr[pos++] = num[data-48];
    // if space
    else if (data == 32) dataArr[pos++] = num[10];
    // if dot
    else if(data == 46) {
      if (pos > 1) bitSet(dataArr[pos-1], 7); 
        else bitSet(dataArr[pos], 7);
    // if carriage return
    else if (data == 13) updateDisp();

void updateDisp() {
  //disable display output
  digitalWrite(OE, HIGH);
  //send data to displays
  int i = 1;
  do {

    for (int e = 0; e <= 7; e++) {
      // send segment data
      digitalWrite(SER, bitRead(dataArr[i],e));
      // toggle clock pulse
      digitalWrite(CLK, HIGH);
      digitalWrite(CLK, LOW);

    dataArr[i] = 0; //fill with space
  } while (i <= dispCount);
  // clear data
  digitalWrite(SER, LOW);
  // toggle clock pulse
  digitalWrite(CLK, HIGH);
  digitalWrite(CLK, LOW);
  // enable display output
  digitalWrite(OE, LOW);
  pos = 1;


Prototypes accepts serial data from USB virtual serial port with following format. It mimics check point times from some sort of sport. Second prototype has two displays, so thats why data needs to be short. Otherwise data will be truncated.


Example picture with that data.

Data is displayed immediately after receiving it and stays on display until new data is arrived. It is possible to clear display temporarily by setting Output Enable pin to high state or clear display memory with sending empty character to all displays.

Selectors J6, J7 and J8

J6 and J7 selects display type between common anode and common cathode. They are solid jumper wires. If mode needs to change then must also change all transistors and reverse on board zener diode. When J6 is position 2-3 and J7 is position 1-2 then display is common anode. And when J6 is position 1-2 and J7 is position 2-3 then display is common cathode.

With J8 its possible to select whether connected display common pins are 1, 8 or 3, 8. Virtually all display modules are supported. Jumpers in position 1-3 and 2-4 means that 3, 8 is selected. When jumpers are in position 1-2 and 3-4 then 1, 8 is selected.

Real Time Clock Timing

Here is a picture of signals between motherboard and rtc clock. RTC uses Intel timing protocol. Pulse duration is about 1µs and time between pulses are about 24µs. AS means Address Select. It functions like clock signal. When DS is low then motherboard wants to read rtc and when RW is low motherboard wants to write to rtc memory. Data protocol is same as generic RAM memory. All this is valid only if MOT pin is connected low. Otherwise Motorola timing is used and it is completely different.

Speeding Up Arduino

This article tells how to overclock Arduino with AtMega328P microcontroller. It is necessary to load new bootloader to Arduino with parallel programmer. Clock speed must be set according the crystal frequency.

I have 22.1184 MHz crystal so I must first edit the Makefile for bootloader. It is located normally in this directory:


Edit correct frequency to this line:

atmega328: AVR_FREQ = 22118400L

Find boards.txt file in the system and change frequency and save.

Next task is to create connection between computer and Arduino. To establish connection you need one parallel port on computer and two resistor in series with the lines.


  • Pin 1 (STROBE), resistor 470 ohm, SCK
  • Pin 2 (D0), resistor 470 ohm, MOSI
  • Pin 11 (BUSY), MISO
  • Pin 16 (INIT), RESET
  • Pin 21 (GND), GND (Any GND will do)

Then open Arduino IDE. Select correct board (Nano in my case) and select Parallel Programmer and finally select “Burn bootloader”. You are ready. Arduino is now running at 22MHz. 🙂 You can program it normally by IDE and can use serial monitor like before.

Simple Four Channel Logic Analyzer/Oscilloscope

This simple program uses four pins of Arduino analog port. On version 0.3 there is about 4ms/division and about 400ms delay between measurements. Also measurements is made only when there is some signal on inputs. Old version 0.1 picture is below.

Version 0.2 image.

Version 0.3 image.

New version 0.3 code.

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"

#define _cs 10
#define _dc 9
#define _rst 8

Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);

volatile boolean measure = false;

void pciSetup(byte pin) {
  *digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin));  // enable pin
  PCIFR  |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
  PCICR  |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group

void setup() {


  tft.drawFastHLine(0,(tft.height()/5)*1, 320, tft.Color565(30,30,30));
  tft.drawFastHLine(0,(tft.height()/5)*2, 320, tft.Color565(30,30,30));
  tft.drawFastHLine(0,(tft.height()/5)*3, 320, tft.Color565(30,30,30));
  tft.drawFastHLine(0,(tft.height()/5)*4, 320, tft.Color565(30,30,30));

int xpos = 0;

  int pin0_state[161];
  int pin1_state[161];
  int pin2_state[161];
  int pin3_state[161];

void loop() { 
  if(!measure) return;
  measure = false;
  unsigned long start = 0;
  unsigned long end_time = 0;


  start = micros();
  for(int i = 0; i < 160; i++) {
    pin0_state[i] = analogRead(0);
    pin1_state[i] = analogRead(1);
    pin2_state[i] = analogRead(2);
    pin3_state[i] = analogRead(3);
  end_time = micros() - start;

  for(int i = 0; i < 320; i=i+2) {
    if(!(i%20)) tft.drawFastVLine(i, 17, tft.height(), tft.Color565(30,30,30));
    else tft.drawFastVLine(i, 17, tft.height(), ILI9340_BLACK);
    tft.drawPixel(i, ((tft.height()/5)*1)-(pin0_state[i/2]/32), ILI9340_YELLOW);
    tft.drawPixel(i, ((tft.height()/5)*2)-(pin1_state[i/2]/32), ILI9340_RED);
    tft.drawPixel(i, ((tft.height()/5)*3)-(pin2_state[i/2]/32), ILI9340_GREEN);
    tft.drawPixel(i, ((tft.height()/5)*4)-(pin3_state[i/2]/32), ILI9340_CYAN);

  tft.setCursor(0, 0);
  tft.fillRect(0, 0, 320, 17, ILI9340_BLACK);
  tft.print((end_time/1000)/16); //one div is X milliseconds
  tft.print("ms/div, int:");
  tft.print((micros() - start)/1000); //interval time

ISR (PCINT1_vect) {
  measure = true;

Here is simple analog datalogger code. Analog value can be between zero and 127. It is viewable with external software.

void setup() {
pinMode(A3, INPUT); 
pinMode(A2, INPUT); 
pinMode(A1, INPUT); 
pinMode(A0, INPUT);


void loop() {

  char testi[101] = {};
  char testi1[101] = {};
  char testi2[101] = {};
  char testi3[101] = {};
  for(byte i=0; i<100; i++) {
    int temp0 = analogRead(0);
    int temp1 = analogRead(1);
    int temp2 = analogRead(2);
    int temp3 = analogRead(3);
    testi[i] = (temp0/8)-1;
    testi1[i] = (temp1/8)-1;
    testi2[i] = (temp2/8)-1;
    testi3[i] = (temp3/8)-1;


Even simpler version that outputs data in CSV format.

void setup() {
pinMode(A3, INPUT);
pinMode(A2, INPUT);
pinMode(A1, INPUT);
pinMode(A0, INPUT);


void loop() {

  char text[101] = {};
  for(byte i = 0; i < 93; i = i + 8) {
    int temp0 = analogRead(0);
    int temp1 = analogRead(1);
    int temp2 = analogRead(2);
    int temp3 = analogRead(3);
    text[i] = (temp0/8)-1;
    text[i+1] = ',';
    text[i+2] = (temp1/8)-1;
    text[i+3] = ',';
    text[i+4] = (temp2/8)-1;
    text[i+5] = ',';
    text[i+6] = (temp3/8)-1;
    text[i+7] = '\n';

Now it’s possible to save and study data right from RTC circuit and motherboard.

Power Supply for old computer

AT standard compliant power lines are +12V, +5V, -12V and -5V. Positive voltages are easy to supply with normal mains adapter, but negative ones are harder to get. Below is schematic of my power supply. It is tested and works ok. Motherboard will start normally.

Photo of the same thing. Other adapter will transform ATX connector to AT P8 and P9 connectors.

-12V is mainly used in serial communication. -5V seems to be used in display adapter board in some sort of op-amp kind of thingy. 🙂 Display is very dim without it.

Self made Cell Phone

I built a cellular phone. It has a touchpad from old laptop and small LCD display. GSM module is SIM800L. Heart of a phone is Arduino Nano. Next I’am going to write a program to it so I can make and receive calls. Touchpad is very unique user interface. Case is made from plastic from old laptop.

Touchpad uses PS2 protocol. GSM modem uses softwareSerial library and LCD display is HD44780 compatible.




There is a place for SIM card in side of a phone and micro USB connector for normal phone charger. Back door is easily removable. It is fixed with magnet.

Optimization and improvements

Some enhangements to second prototype of New RTC Replacement Module. New circuit board is ordered from China and is coming soon.

Improved schematic diagram. Added memory capacitor and support circuit that allows use of smaller limiting voltage capacitors. PCF8563 is deprecated and replaced with PCM8583. Program code needs appropriate changes too.

Prototype is ready for testing

Ready made prototype of New RTC Replacement Module. Battery is replaced with 0.68F memory capacitor.

To transfer program in to AVR which has Arduino bootloader installed is possible with USB to UART board. Only one 100nF capacitor is needed.

Connection UART – AVR
  • GND – GND
  • +5V – +5V
  • TX – RX
  • RX – TX
  • DTR – 100nF cap – RESET