Skip to main content

Posts

Interface Push Button To Atmega328 with Input Pullup

     In previous tutorial we learned how to interface a LED to Atmega328 and then wrote the code in Atmel Studio to make it go 'ON' and 'OFF' after every one second. In short we learned how to use our MCU's port pin as a simple digital output. In this tutorial we will be using a push button as an input to turn LED on for certain duration.      Like last tutorial we will be using PORTB for our purpose. We will be using PB5(Pin 19) as output and PB1(Pin 15) as input. In this tutorial we will be using Current Sink method to interface LED with the mcu, whereas internal pullup method for interfacing the pushbutton. The following image shows the circuit we need to assemble. Schematic for Interfacing LED and Button What is Current Sinking?      When the current flows from power supply to load and then to the Microcontroller's pin (or any other device) the configuration is called Current Sinking. In our circuit Power Suppl...

Creating The First Project in AS7 and Blinking a LED

     Assuming that you have followed the previous tutorials and set up environment for AVR development using Atmel Studio, let us now see how to create a new project in Atmel Studio 7 (AS7). Please take note that while Installing Atmel Studio it will ask permission for installing packages for 8/32bit AVR micro-controllers as well as ARM series, make sure you select the packages for 8/32bit avr micro-controllers.  Step 1      After starting the AS7, you will see the welcome screen in which you can see lots of tools in toolbar and 'Start Page' in tab section. Under that tab look for 'Start' under which lie the 3 options New Project, Open Project and New Example Project. Click on 'New Project' or you can go in file menu and select project under new sub-menu. Atmel Studio 7 home screen  Step 2      Once you choose to create a new project in Atmel Studio, a dialog box will pop up to ask what programming lan...

Atmega328/P: Basic Circuit and Configuring Fuse Bits

     Now that you have probably installed the driver for USBasp , it's time that we move on to mount the basic circuit for Atmega328 and get it running on the breadboard. You can get a new Atmega328/P micro-controller or just scavenge one from an Arduino UNO lying around. Before we mount the circuit on breadboard here's the of components that are required. Atmega328/P (28 PIN DIP package) 22pf Ceramic Capacitors Qty 2 nos. 16MHz crystal Qty 1 nos. [have 2-3 in spare just in case the one in use is damaged] Tactile Switch/Push Button Qty 1 nos. Resistor 10K Ohm Qty 1 nos. LED 1 nos. Breadboard Connecting Wires       The schematic below shows how to configure Atmega328/P on breadboard. I have posted a hand drawn schematic as well as an eagle schematic. Before you mount the circuit lets understand functions of pin that we are using to make a basic circuit of Atmega328/P. Configuring Atmega328/P [Click to Open) Pin 1 [PC6(RE...

USBasp: Driver Installation

     USBasp is an in-circuit programmer for Atmel micro-controllers. It is a nice option if you're just starting with micro-controllers, especially those from Atmel and aren't willing to spend much on a programmer. USBasp uses in-circuit programming interface for uploading your compiled code to the micro-controller.      Before we can use the USBasp we need to make sure that we install the drivers correctly. If you are a Linux or Mac OS user, there's no need to install any driver as your machine will automatically detect the USBasp. So driver installation comes for Windows user like me. It is easy to install the drivers for USBasp, all you need to do are just carry out few steps that I will be telling. Step 1      Download the Zadig application from here . Zadig is an application that has a set of some generic usb drivers and one of them is for USBasp. Now plug in USBasp before running the application. Step 2  ...

Setting Up

     Before moving to actual tutorials, I will list out few basic hardware and software that will be required. I will also tell the need of these items in this post. I will also provide the links of the software and datasheets.       Following is the list of the required hardware: Breadboard for mounting any circuit Connecting Wires: You can use standard single stranded wires or jumper cables Atmel's Atmega328-PU or Atmega328P-PU: This is a 28 PIN 8 bit micro-controller, you can get those easily in the market. You can also use any other 8 Bit micro-controller from Atmel, like Atmega8, Atmega168, Atmega16, etc. Since my tutorials will be mostly first conducted on Arduino Board and then standalone micro-controller I will suggest anyone from Atmega328/328P. I will be using Amega328-PU. Arduino Development Board: This hardware is totally optional. I will be using arduino hardware just to demonstrate the program difference between Arduino ...