Micyo Con troller EE 354 Assignment 4 A/D and PWM Sept. 27, 2017 Due: October 13, 2017 For this project you will read the value on a potentiometer using the A/D converter and use that value to adjust the duty cycle that an LED is turned on using PWM. This will allow you to make a dimmable LED The A/D converter has a reference voltage of 2.5 volts and its input should not exceed this value Likewise the input should not go below zero. Use the potentiometer arrangement show below on the A/D channel zero. The value of R should be either 1K, 5 K, or 10 K. Connect an LED to PWM Channel 0. This arrangement allows the user to select an A/D input voltage from 0 to 2.5 volts. Write a program to accept this input and produce a PWM signal on channel 0 which has a duty cycle proportional to the A/D voltage Your program must be written entirely in C-code +5V +5V 1K P1.0 ADC0 P1.3 PWMO
Explanation / Answer
#include // register function sbit LED = P2^0; // LED pin void Delay(void); void main (void) { while(1) { LED = 0; // LED ON Delay(); LED = 1; // LED OFF Delay(); } } void Delay(void) { int j; int i; for(i=0;i