This application uses the ADC to measure an analog input voltage, typically from a potmeter. It uses the sampled value to control the PWM duty cycle of an I/O pin, typically connected to a LED. The printf() will be redirected to USART to print status information, while the Timeout Driver schedules the timing of these operations. This results in a LED dimmer and printf() application.
- MPLAB® X IDE 6.25 or later
- ATtiny DFP 3.3.272 or later
- MPLAB® XC8 3.00 or later
- AVR/GNU C Compiler 5.4.0 or later
- ATtiny817 Xplained Pro
- Micro-USB cable (Type-A/Micro-B)
-
Connect ADC Channel 3 (PA3) to analog input voltage source, such as potmeter.
-
Connect PWM Channel 0 (PB0) to observable output, such as a LED.
-
Connect the ATtiny817 Xplained Pro board to the PC using the USB cable.
-
Download the zip file or clone the example to get the source code.
-
Open the project in MPLAB X IDE.
-
Build the solution and program the device.
-
Open the EDBG COM-port in a terminal window to observe the printf() output.
-
Operate the analog input voltage source (e.g. potmeter) and observe the change in LED and printf() output.
This code example has illustrated how to use basic peripherals of the ATtiny817 to create a LED dimmer and printf() application.