This tiny project shows how to interface LED to the microcontroller ATtiny13 and write a simple program to make it blink. The code is on Github, click here.
LEDs are widely used for various display functions and can be directly (not quite directly, through the resistor) driven from the pins of AVR chip. In our circuit a LED is connected to PB0 and it is made to blink for roughly every second by using delay function.
Parts Required
- ATtiny13 – i.e. MBAVR-1 development board
- Resistor – 220Ω, see LED Resistor Calculator
- LED
Circuit Diagram
Software
This code is written in C and can be compiled using the avr-gcc. More details on how compile this project is here.
#include <avr/io.h> #include <util/delay.h> #define LED_PIN PB0 // PB0 as a LED pin int main(void) { /* setup */ DDRB = 0b00000001; // set LED pin as OUTPUT PORTB = 0b00000000; // set all pins to LOW /* loop */ while (1) { PORTB ^= _BV(LED_PIN); // toggle LED pin _delay_ms(500); } }
Hi…
I want to build this project using BASCOM AVR.. maybe u can help me to build the coding … thx u.