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.