Note : the PWM pins are identified with a “~” sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
echo '' ;
Note : UN-command the line depend on your preferred compiler.
//www.ArunEworld.com/embedded/microchip/pic_mcu/ #include<pic.h> // for Hi-Tech Compiler #define _XTAL_FREQ 4000000 //short currduty1=16; void init() { PORTB=0X00; TRISB=0X0f; } void pwm_dutycycle(unsigned int duty) { CCPR1L=duty; CCP1CON&=0xCF; CCP1CON=(CCP1CON|(0X30&(duty<<4))); } void pwm_init() { TRISC=0X00; CCP1CON=0X0C; PR2=96; TMR2=0; T2CON=0x7B; pwm_dutycycle(0); T2CON=0X7F; } void delay(unsigned int de) { while(de--); } void main() { pwm_init(); while(1) { if(RB0) { /*delay(100);*/ pwm_dutycycle(0); } if(RB1) { /*delay(100);*/ pwm_dutycycle(64); } if(RB2) { /*delay(100);*/ pwm_dutycycle(128); } if(RB3) { /*delay(100);*/ pwm_dutycycle(255); } } }
Next :
previous :
Playing the Imperial March ringtone on an ESP8266 NodeMCU involves using the NodeMCU’s capabilities to generate sound or control an external sound module. One common method is using a piezo buzzer to generate tones. Here’s a basic example of “ESP8266 Imperial March Ringtone play” using the NodeMCU and a piezo buzzer to play the Imperial March:
You must be logged in to post a comment.