Atmega32 Super Blinky Part V: Getting started with the Atmega32


This is the C code used in the above video:

// SuperBlinky.c
//
//Iterative multiplication and division of a binary number by 2
//Display of result on PORTB
//
//Created: January 17, 2013  11:31AM EST
//Author: Holger Marten
 
 
                               
#include <avr/io.h>                        //Include standard input output library
#define F_CPU 1000000UL          //Let libraries know that CPU runs at 1000000 cycles/second
#include <util/delay.h>                 //Include library that has delay functions
int main (void)
{
                int i = 0;                //Set initial value that will be displayed on port B             
               
                DDRB = 0xFF;     // set all pins on PORTB for output
                while(1) {
                                for(i = 1; i < 128; i = i*2)  //Loop that keeps on multiplying by                                                                                     //2 and storing value in i
                                {
                                                PORTB = i;                           //Assign value in i to PORTB       
                                                //_delay_loop_2(30000);
                                }
                                for(i = 128; i > 1; i -= i/2) //Loop that keeps on dividing by 2 and                                                                                  //storing value in i
                                {
                                                PORTB = i;                           //Assign value in i to PORTB
                                                //_delay_loop_2(30000);
                                }
                }
                return 1;
}

Atmega32 Super Blinky Part IV: Getting started with the Atmega32


This is the C code used in the above video:

// SuperBlinky.c
//
//Iterative multiplication and division of a binary number by 2
//Display of result on PORTB
//
//Created: January 17, 2013  11:31AM EST
//Author: Holger Marten
 
 
                               
#include <avr/io.h>                        //Include standard input output library
#define F_CPU 1000000UL          //Let libraries know that CPU runs at 1000000 cycles/second
#include <util/delay.h>                 //Include library that has delay functions
int main (void)
{
                int i = 0;                //Set initial value that will be displayed on port B             
               
                DDRB = 0xFF;     // set all pins on PORTB for output
                while(1) {
                                for(i = 1; i < 128; i = i*2)  //Loop that keeps on multiplying by                                                                                     //2 and storing value in i
                                {
                                                PORTB = i;                           //Assign value in i to PORTB       
                                                _delay_loop_2(30000);
                                }
                                for(i = 128; i > 1; i -= i/2) //Loop that keeps on dividing by 2 and                                                                                  //storing value in i
                                {
                                                PORTB = i;                           //Assign value in i to PORTB
                                                _delay_loop_2(30000);
                                }
                }
                return 1;
}