Introduction: Self-made Arduino Board
By designing your own Arduino-Board you will learn about some new components and electronic circuits, including some advanced topics like power supply, timing circuit and the use of ATmega IC (Integrated Circuit).
It will help you in the future with creating your own projects like weather station, home automation shields etc.
The advantage of the self-made Arduino is that it has a low energy consumption and ensures that a project can run for a long time on a battery.
Additionally you can expand the board by adding digital or analog port expansion or some communication modules.
To build a minimalist Arduino, you’ll need the following hardware:
1x ATmega328P-PU microcontroller with Arduino bootloader
1x 7805 linear voltage regulator (5v output, 35v max input)
1x breadboard (I am using 830 pin board)
Various connecting wires
1x 16 MHz crystal oscillator
1x 28 pin ic socket
1x 1 μF, 25 V electrolytic capacitor
1x 100 μF, 25 V electrolytic capacitor
2x 22 pF, 50 V ceramic capacitors
2x 100 nF, 50 V ceramic capacitors
2x 330 Ohms resistors (R1 and R2)
1x 10 kOhm resistor (R3)
2x LEDs of your choice (LED1 and LED2)
1x push button
Optional 2x 6-pin header and 3x 8-pin header
1x PP3-type battery snap
1x 9 V PP3-type battery
1x FTDI Programming adapter
Step 1: 7805 Linear Voltage Regulator
A linear voltage regulator contains a simple circuit that converts one voltage to another. The 7805 regulator can convert a voltage between 7 and 30 volts to a fixed 5 volts, with a current up to 1 amp, which is perfect for our Arduino-board.
We will start with creating the power supply circuit which contains a 7805 voltage regulator in TO-220 form and two capacitors with 100 μF each.
When you are looking at the front of the 7805 chip - the pin on the left is for the input voltage, the center pin connects to GND and the right-hand pin is the 5 V output connection. I would recommend to place a heat sink, because when the circuit draws up to the maximum of 1 amp of current the 7805 chip will be quiet hot (you can burn your finger tip when you touch it).
Place a 100 μF capacitor between the IN of the regulator and the ground and a100 μF capacitor on the
right rail between power and the ground. You must be careful - the electrolytic capacitor is polarized (the silver strip on the capacitor signifies the ground leg) and must be placed exactly according to the schematic.
Add power and ground wires for where your voltage regulator will be, connecting
each rail in the middle and at the right part of the board. In this way we have 5 Volt power supply from top and bottom rails of the breadboard. Additionally we will include a red LED that is lit when the power is on, in this way we can always see when our board is powered.
A LED is a diode and it only allows electrical current to flow in one direction. Electricity should flow into the long leg and out of the short leg. The LEDs cathode also has one slightly flattened side, which corresponds with the short, negative leg of the LED.
Our circuit has a 5 volts power supply and a red LED is rated around 1.5 - 2 volts. To reduce the voltage we must connect the resistor in series with the LED limiting the amount of electricity flowing to prevent the LED destruction. Some of the voltage will be used up by the resistor and only a suitable share of it is applied across the LED. Insert the resistor between the short leg of the LED and the row containing the black wire on the right hand side of the chip (GND).
The red and black wires to the left of the voltage regulator is where your power supply will be plugged in. The red wire is for the POWER and the black wire is for the ground (GND).
NOTE: You can only attach a power supply that is between 7-16V. Any lower and you won't get 5V out of your regulator, and voltage higher the 17 V will damaged your chip. A 9V battery, 9V DC power supply, or 12V DC power supply is suitable.
And for some more advance circuits you can place a voltage regulator with adjustable voltage. In this way you can add some 3.3 V sensors to the board or power up a 9 V DC motor.
More about linear voltage regulators -
Step 2: ATmega328P-PU Microcontroller
To build an Arduino on the breadboard you need an ATmega328P-PU microcontroller which
is the brain of our self-made Arduino-board. Place it as shown in the schematics and be careful - the legs can break if you force them in, or you can use 28 pin IC socket. IC should be placed with a moon shape cut oriented to the left of the breadboard (pins are numbered from 1 to 28 counterclockwise).
NOTE: Not all ATmega IC contain the Arduino bootloader (the software that allows it to interpret sketches written for an Arduino). When looking for a microcontroller for your self-made Arduino, be sure to select one that already includes the bootloader.
Here a bit of microcontroller theory.
A microcontroller is a tiny computer with a processor that executes instructions. It has various types of memory to hold data and instructions from our program (sketch); ATmega328P-PU has three types of memory: 32kB ISP (in-system programming) flash memory where sketches are stored, 1kB EEPROM (electrically erasable programmable read-only memory) for long-term data storage and 2kB SRAM (static random-access memory) for storing variables when a sketch is running.
NOTE: It is important to know that data in flash memory and EEPROM is retained when power to the microcontroller is removed.
The microcontroller has 13 digital general-purpose input/output (GPIO) lines and six 10-bit (values between 0 and 1023) analogue to the digital converter (ADC) GPIO lines to convert the voltage on a pin to a digital value. There are three timers with two 8-bit timers with values between 0 and 255, and one 16-bit timer with values between 0 and 65535, which are used by the delay() function in a sketch or by pulse width modulation (PWM).
There are five software selectable power-saving modes and the microcontroller operates between 1.8V and 5.5V. You can use the picture as a reference for the pin layout of the ATmega328P-PU.
There are three groups of ports: PB, PC, and PD with 8, 7, and 8 pins respectively, plus two ground (GND) pins, a 5V pin (VCC) with supply voltage (AVCC), and analog reference voltage (AREF) pins for the analog-to-digital converter (ADC).
Step 3: ATmega328P-PU Interconnection
After placing IC, connect pins 7, 20, and 21 of the ATmega to the positive
power rail on the breadboard, and pins 8 and 23 to the negative power rails, use jumper wires to connect the positive and GND power rails on either side of the board, as shown in the Figure.
Pin 7 - Vcc - Digital Supply Voltage
Pin 8 - GND
Pin 22 - GND
Pin 21 - AREF - Analog reference pin for ADC
Pin 20 - AVcc - Supply voltage for the ADC converter. Needs to be connected to power if ADC isn't being used as in our example. If you would like to use it in the future then it must be powered via a low-pass filter (to reduce noise).
After that place some fourteen-way header pin – it will be similar to the Arduino GPIOs.
Step 4: Reset Button
Add the small tactile switch so that you can reset the Arduino and prepare the chip for uploading a new program. A quick momentary press of this switch will reset the chip.
We will insert the reset button in our circuit as shown in the figure, when we press it the electric circuit will be shortened to the GND bypassing a 1kOhm resistor and connecting the ATmega Pin 1 to the GND. Then, add a wire from the bottom left leg of the switch to the RESET pin of the ATmega chip and a wire from the top left leg of the switch to the ground.
Additionally, add a 10 k Ohm pull-up resistor to +5V from the RESET pin in order to prevent the chip from resetting itself during normal operation. This resistor will be connected to the 5 volt power supply, 'pulling up' Pin 1 to 5 volts. And when you connect Pin 1 to 0V without a resistor, the chip will reboot. On the reboot microcontroller look for a new program being uploaded (on power-up if nothing new is sent, it runs the last program sent).
The resistor has a four colored stripe. Reading Brown=1, Black=0, Orange=3 gives us the number 103. The resistance in Ohms starts ‘10’ with 3 zeroes after - 10,000 Ohms or 10 kilo Ohms, and the gold stripe is the tolerance (5 %).
To upgrade our circuit – we can place ’decoupling’ capacitor`. Place a 100 nF (nano Farad) ceramic capacitor. It is a small disc with two wires with '104 marking' and this type of capacitor is none polarized and can be placed in any orientation.
This ‘decoupling’ capacitor smoothes electrical spikes, so the reboot signal sent through to Pin 1 is reliably detected. The digits 104 show its capacitance in pico Farad in scientific notation. The last figure '4' tells us how many zeroes to add. The capacitance starts ‘10’ and then continues with a further 4 zeroes - 100,000 pico Farads, and since 1000 pico Farads is 1 nano Farads, there are 100 nano Farads (104).
Insert the capacitor between the top left leg of the chip (pin 1, anticlockwise from the half-moon shape)
Step 5: Crystal Oscillator
Now we will make the clock for the IC. It is a 16 Mhz quartz and two ceramic capacitors 22pF (piko Farad) each. The crystal oscillator creates an electrical signal with a very accurate frequency. In this case, the frequency is 16 MHz, which means that microcontroller can execute 16 million processor instructions per second.
The 16 MHz crystal (figure) allows the Arduino to calculate time, and the capacitors serve to smooth the supply voltage.
The quartz crystal legs are both the same - you can't wire it backwards. Connect one leg of the crystal to pin 9 on the ATmega chip, and the other leg to pin 10. Connect the legs of one of the 22 pF disc capacitors to pin 9 and GND, and other disc capacitor to pin 10 and GND, as shown in Figure.
Note: disc capacitors are non-polarized and can be inserted in any way.
It is worth to mention, that the wire lengths between the 22pF capacitors must be equal in length and should be as close as possible to the controller to avoid interactions to other parts of the circuits.
Step 6: Adding LED to Pin 13
Now we will add the green LED (digital pin 13 on Arduino).
Insert a LEDs long leg to the row below the red wire (on the right hand side of the chip - power, or 5 Volts) and the short leg in the first empty row below the microcontroller.
This 330 Ohm resistor is connected in series with the LED, limiting the amount of electricity flowing to prevent the LEDs destruction.
Insert the resistor between the short leg of the LED, and the row containing the black wire on the right hand side of the chip (GND or 0Volts)
All the analog, digital, and other pins available on the normal Arduino board are also available in our breadboard version. You can use the ATmega schematic and pin table as a reference.
Step 7: USB to Serial Connector
The ATmega 328P-PU microcontroller provides three communication modes: a serial programmable USART (universal synchronous and asynchronous receiver-transmitter), an SPI (Serial Peripheral Interface) serial port, and a two-wire serial interface. USART takes bytes of data and transmits the individual bits sequentially, which requires transmit (TX) and receive (RX) communication lines. SPI uses four communication lines: master-out slave-in (MOSI), master-in slave-out (MISO) and serial clock (SCK) with a separate slave select (SS) line for each device. The I2C communication Two Wire Interface (TWI) bus uses two signal lines: serial data (SDA) and serial clock (SCL).
To connect our board to the PC with Arduino IDE for downloading a sketch, we will use a USB to serial UART interface such as the FT232R FTDI.
When purchasing an FTDI cable make sure it is the 5 V model, because the 3.3 V model will not work properly. This cable (shown in figure) has a USB plug on one end and a socket with six wires on the other.
When you are connecting the cable, be sure that the side of the socket with the black wire connects to the GND pin on the breadboard’s header pins. Once the cable is connected, it also supplies power to the circuit, just like a normal Arduino board would do.
Then we will connect our FTDI with our self-made Arduino-board; for reference you can use the table and the schematic.
A 0.1μF electrolytic capacitor is connected between the DTR (Data Terminal Ready) pin on the USB to serial UART interface and the microcontroller Reset, which resets the microcontroller to synchronize with the USB to the serial interface.
NOTE: Oneclever part is that microcontroller RX pin must be connected to the TX of the USB to the Serial adapter and the same with TX of one device to RX of the other.
The CTS (Clear to Send) pin on the USB to the serial UART interface is not connected to the microcontroller.
To download a sketch to the microcontroller in the Arduino IDE from the Tools ➤ Port menu select the relevant communication (COM) port and from the Tools ➤ Board menu select Arduino/Genuino Uno. The sketch is compiled in the Arduino IDE and then loaded to the microcontroller with the USB to the serial UART interface. When the sketch is downloaded, the green and red LEDs of the USB-to-serial UART interface TXD and RXD flicker.
The USB to serial UART interface can be removed and a 5V power supply connected to the microcontroller. An LED and 220kΩ resistor are connected to the microcontroller pin 19, equivalent to Arduino pin 13, to run the blink sketch.
Step 8: Uploading Sketch or Installing the Bootloader
If you don’t have an USB to serial converter – you can use another Arduino (in my case Arduino UNO) to upload a sketch or bootloader to the self-made board.
The ATmega238P-PU microcontrollers require a bootloader for uploading and running sketches from the Arduino IDE; when power is applied to the microcontroller the bootloader determines if a new sketch is being uploaded, and then loads the sketch into the microcontroller memory. If you have the ATmega328P-PU without a bootloader, then you can upload the bootloader using SPI communication between two boards.
Here is how you upload a bootloader to the ATmega IC.
First let’s start with configuring our Arduino UNO as ISP, this is done because you want the Arduino UNO to upload the sketch to the ATmega IC and not itself.
Step 1: Configuring our Arduino UNO as ISP
Don't connect the ATmega IC while the below upload is running.
- Plug the arduino to a PC
- Open the arduino IDE
- Select the appropriate Board (Tools > Board > Arduino UNO) and COM Port (Tools > Port > COM?)
- Open > Examples > ArduinoISP
- Upload Sketch
After that you can connect your own Board to the Arduino UNO by following the circuit as shown on the schematic. At this stage there is no need to power supply your own board as the Arduino would provide the necessary power.
Step 2: Uploading a Sketch or Bootloader
With everything connected open the IDE from the folder you just created (the copy).
- Select Arduino328 from Tools > Board
- Select Arduino as ISP from Tools > Programmer
- Select Burn Bootloader
After a Successful burn you would get a "Done burning bootloader".
The bootloader is now loaded onto the microcontroller, which is ready to receive a sketch after changing the COM port in the Tools ➤ Port menu.
Participated in the
First Time Author Contest