标题: 电位器控制8彩灯闪烁速度的疑问 [打印本页]

作者: charles79    时间: 2017-2-28 00:55
标题: 电位器控制8彩灯闪烁速度的疑问
8彩灯闪烁的程序已经写好,pwm脉宽调制的程序不会写,有没有谁能帮忙看一下。
  1. #define F_CPU 4000000UL
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4. #define INT8U unsigned char

  5. const INT8U Pattern_P0[]=
  6. {
  7.         0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0xff,0x00,0xff,0x7e,0xbd,0xdb,0xe7,0xc3,0x81,0x00
  8. };
  9. const INT8U Pattern_P1[]=
  10. {
  11.         0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0xff,0x00,0xff,0x7e,0xbd,0xdb,0xe7,0xc3,0x81,0x00
  12. };

  13. int main(void)
  14. {
  15.     INT8U i;
  16.         DDRC=0XFF; PORTC=0XFF;                        //配置端口
  17.         DDRD=0XFF; PORTD=0XFF;
  18.     while (1)
  19.     {
  20.                 for (i=0;i<19;i++)                        //循环显示全部花样字节
  21.                 {
  22.                         PORTC= Pattern_P0[i];        //第一组发送给PORTC端口
  23.                         PORTD= Pattern_P1[i];        //都二组发送给PORTD端口
  24.                         _delay_ms(80);
  25.                 }
  26.     }
  27. }
复制代码




作者: charles79    时间: 2017-2-28 01:06
现在不带电位器彩灯花式闪烁的程序已经写好了,电位器带电机调速的也成功了,但是两者不知道怎么整合到一起,有没有谁能帮忙看一下




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1