Tutoriais do microcontrolador ATtiny85, Parte 5: Controle de intensidade de LED usando ATtiny85

ATtiny85 Microcontroller Tutorials Part 5: LED Dimmability Control Using ATtiny85

In previous tutorials in this series, we saw how to generate different chase effects by flashing LEDs. So we were simply turning the LED on and off.

In this tutorial we will vary the brightness (intensity) of the LED. We will use the ATtiny85's PWM output to do this. So let's see how to do this.

If you are not following this tutorial series from the beginning, you should go through the following two tutorials that explain and demonstrate how to work with ATtiny85 and step-by-step guide to building a hello world (blinking LED) app.
How to work with ATtiny85
LED blinking using ATtiny85

Circuit Diagram

Circuit Connections
The circuit diagram is very simple. Only one LED is connected to PB0 pin (pin 5), which is also the PWM output pin. A 330 resistor is used to limit the current. A 5V supply is connected to a Vcc pin (8).

Program
The program is written in Arduino IDE software using the C programming language. It is compiled and a HEX file is created that is downloaded to the ATtiny85's internal FLASH.

Program logic
The program logic is straightforward. First, the PWM output is gradually increased from 5 to 255 (maximum width) in increments of 10. This PWM is given to the LED, so its intensity will gradually increase. The LED intensity goes from 0 (min) to full (max) in 5 seconds. Then the PWM output gradually decreases from 255 to 0 in increments of 10. Thus, the LED intensity will gradually decrease from maximum to minimum again in 5 seconds. Once again the PWM value begins to increase and this cycle repeats itself continuously. Therefore, the LED intensity increases and decreases continuously.

program code

In the next tutorial we will learn how to vary the LED brightness using a potentiometer.

Conteúdo Relacionado

How to Troubleshoot Common ESP32-CAM Problems
ESP32-CAM is a compact camera module that combines the...
What is the role of automotive sensors in modern vehicles?
A network of sensors is embedded in every vehicle,...
How to choose an e-bike controller
The motor controller is one of the most important...
A guide to USB standards from 1.0 to USB4
A evolução dos padrões USB foi fundamental para moldar...
Schurter aprimora série de seletores de tensão com revestimento prateado
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A interface serial PCI fornece conectividade confiável em ambientes extremos
A Sealevel Systems anuncia o lançamento da Interface Serial...
STMicroelectronics expande portfólio de conversão de energia com diodos Trench Schottky de 100 V
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
O que são Sistemas Globais de Navegação por Satélite (GNSS) e como são usados?
Determinar uma localização precisa é necessário em várias indústrias...
O conversor GaN de 50 W da STMicroelectronics permite projetos de energia de alta eficiência
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
Samsung e Red Hat farão parceria em software de memória de próxima geração
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
Primeiro MPU single-core com interface de câmera MIPI CSI-2 e áudio
O mercado embarcado tem uma necessidade de soluções de...
Fluency decoding in induction motor for better performance
You have probably come across the term ' drag...
Understanding Support Insulators in Electrical Systems
You probably have a support insulator if you've noticed...
Explore Stay Insulator – safety, installation and maintenance
You've probably seen stand an insulator sit on power...
More safety and efficiency with the shackle isolator
You've probably seen shackle insulators enthroned on electricity poles,...
Discover the power of latching relays for energy efficiency and more
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.