Arduino Uno to ATme...
 
Notifications
Clear all

Arduino Uno to ATmega328 - Shrinking your Arduino Projects

36 Posts
7 Users
6 Likes
4,586 Views
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1076
Topic starter  

Learn how to transfer your Arduino Uno projects to an ATmega328 Chip.

Full article at https://dbot.ws/atmega328
Star Wars music sketch on GitHub - https://gist.github.com/nicksort/4736535

In this final episode of 2018, I will show you how to take the projects you have built using an Arduino Uno and “shrinkify” them down to an ATmega328 chip. This will allow you to make a permanent version of your project without using up one of your precious Arduino boards.

The ATmega328 is the microcontroller chip at the heart of the Arduino Uno. It is available in several packages, we will focus on the common 28-pin DIP (Dual Inline Package).

You only need a handful of components to turn an ATmega328 chip into a fully-functional Arduino Uno equivalent. It’s much cheaper and a lot smaller, allowing you to build a permanent version of your design onto a small circuit board.

I will also show you three methods of programming the ATmega328 chip, after all an Arduino isn’t very useful if you can’t upload a sketch to it!

To illustrate my point I will put together a very simple yet cute “music box” using an Arduino Uno, and then we’ll move the project onto an ATmega328. It will be of particular interest to Star Wars fans as the “music box” plays “The Imperial March”. If you have an old Darth Vader or Storm Trouper toy it would be neat to build it into it!

I cannot take any credit for the sketch I used to create the Star Wars music box, the code was written by Nick Sort about 6 years ago and is available on GitHub - https://gist.github.com/nicksort/4736535 <. It’s an excellent example of making simple music with the Arduino.

Here is the Table of Contents for this video:

00:00 - Introduction
03:29 - The ATmega328
05:50 - Star Wars Arduino Project
08:35 - Star Wars Sketch
15:14 - Build an “Arduino” with ATmega328
21:31 - Loading the Program - Using Arduino Method 1
24:50 - Loading the Program - Using Arduino Method 2
30:01 - Loading the Program - Using FTDI Adapter

As always you will find an accompanying article for this video on the DroneBot Workshop website at https://dbot.ws/atmega328.

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ron bentley reacted
Quote
Sid
 Sid
(@sid)
Member
Joined: 3 years ago
Posts: 111
 

Thank you @dronebot-workshop for this video and also for having it up here for discussion. If I may, I have a few questions -

1. On the official Arduino site and their forum - a lot of people have been telling for having some de-coupling resistors for those standalone circuits. I do understand that these "extra" resistors and "capacitors" are supposed to stabilize the supply of power. But if that is the case, why do people still create those stand-a-lones without the extra stuff?

2. I tried doing a circuit based on your video but it went wrong (this was before I had joined here). I posted it on Arduino Forums and someone pointed out that the FTDI was wrongly used. I realized only after its mention that my schematic (that I created using EasyEDA) had its compontent pin out that was wrong. So got that changed on the schematic, but then no one bothered to respond. Here is the last schematic - if anyone could confirm if it is good or I need to remove or add anything (component), it would be of great help.

Schematic Revised 2

Life is exploring and learning


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
 

Sir, if I buy a fresh atmega328 from the market and try to program it using the FTDI, will it be a problem? Or will I have to burn bootloader in the chip first?


   
ReplyQuote
Sid
 Sid
(@sid)
Member
Joined: 3 years ago
Posts: 111
 
Posted by: @sumanta

Sir, if I buy a fresh atmega328 from the market and try to program it using the FTDI, will it be a problem? Or will I have to burn bootloader in the chip first?

There are two different types of ATMEGA-328P available in the Indian market - 1.  pre-loaded with bootloader (you do not have to load it again) and 2. without any bootloader (so you need to load it yourself). And cost-wise, they are not expensive (a mere difference of 25 INR at my place). So always advisable to buy ones that have bootloader preinstalled.

The other non documented advantage is - you can trust the preinstalled ones more just because they have already been used whilst bootloading - chances of a faulty IC at least is reduced.

And a personal experience note - Avoid getting these from Amazon and other online stores - not onlyy they are expensive but also, there is no guarantee that if you order "pre bootloaded", you would get pre bootloaded. I had purchased 4 of pre bootloaded from Amazon, got all junk. And the seller said as it is an electronic chip, I might have ruined them while operating. So be careful of that kind of experience in case you opt in for "online" purchase.

The pre-bootloaded ones can be used without much fuss and as shown in the video.

 

Life is exploring and learning


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
 

@sid 

Thank you for the information and your advice 😃


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
 

@sid

But there's a problem. Even if I buy it offline, how can I verify that the chip is preloaded with bootloader? Even the shopkeeper can cheat me.


   
ReplyQuote
Sid
 Sid
(@sid)
Member
Joined: 3 years ago
Posts: 111
 
Posted by: @sumanta

@sid

But there's a problem. Even if I buy it offline, how can I verify that the chip is preloaded with bootloader? Even the shopkeeper can cheat me.

It would depend on your trust of the store - normally they wont cheat you here because they know, you will be a prospective client who will make further purchases of other Arduino components from them. Not so when you buy online. I think you are unnecessarily getting worried here because if you can trust your store for your other components, there is no reason you should not trust them for your ATMEGA chips as well.

The only thing I wanted to convey on my earlier reply was - buying it offline at a store, you have a more higher percentage of getting what you are asking for.

Life is exploring and learning


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
 

@sid

Okay. Thank you for the reply 😀 


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 

@sumanta

An exercise worth attempting is the process of flashing the bootloader yourself.  You'll learn some invaluable lessons in doing so!

SteveG


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
 

@codecage

Yeah that's right. But I was asking this question on behalf of a friend of mine. He doesn't have an Arduino. So he was asking me for an alternative. Because, for flashing the bootloader, you need an Arduino.


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 

@sumanta

If you put one together you will learn and then be able to help him learn as well.

SteveG


   
Sid reacted
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
 

@codecage

Yes. That's an idea.


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
 

@sid

Hi. You can look at the chip and tell whether it has preloaded bootloader or not. If the name is "Atmega328p-pu" then it has bootloader. Otherwise not. Hope this helps. 🙂 


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 

@sumanta

Are you sure about your post?  Where is this information about the designator "PU" confirmed.  I have been unable to find it. 

SteveG


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
 

@codecage 

Watch the above video. It's said there.


   
ReplyQuote
Page 1 / 3