0
收藏
微博
微信
复制链接

闲在家没事做了个单片机RDA5807M调频收音机 附代码

提问于
2024-04-02 01:55

      用手头的零件做个数字收音机,收音模块5807M,IIC通讯,0.91寸OLED IIC通讯的,EC11,一对一编码器,自带一个按键,就用编码器+自带按键操作,单片机翻了翻盒子,发现两片STC15W408AS,就这个了。
      折腾了两天,昨晚上调试成功,今天整了一份Kicad的图纸,带自己随便画的一个小板图,还有程序全套。

制作出来的实物图如下:
a39cbb529ee6f0c150aa859a5d67f9.png
a9e6dcbe247a31f287c3d7413bb055.png
4b88e5eda9820f2d7430c8aa8f9add.pngdeb085b1d2da1361bf391d6943a77e.png

电路原理图如下:
37cadf718ed2b5d0e5667d0390fd25.png990855181c9d70fe44f04702a50474.png

单片机源程序如下:

  1. /*---------------数字调频收音机------------------*/
  2. /*           学习之用,请勿商用                  */
  3. /*           转载请注明:数字收音机RDAV1.0       */
  4. /*-----------------------------------------------*/

  5. #include
  6. #include
  7. #include
  8. #include<5807.h>
  9. #include
  10. #include
  11. void main()
  12. {
  13.         u8 keynum;
  14.         u32 rxfreq=9480,vol=2,tn,vol1,xfreq,yfreq;
  15.         oledinit();       
  16.         oledbmp(0,0,128,4,BMP1);
  17.        
  18.         rdainit();  //RDA5807 初始化
  19.         freqset(rxfreq);  //频率设置
  20.         volset(vol);      //音量设置
  21.         seeset(6); //搜台灵敏度设置,灵敏度太高会导致杂音,越小灵敏度越高,最大15。
  22.         seektion(1);
  23.        
  24.         delay_ms(3000);
  25.         oledclr();
  26.         oledchine(0,0,0);
  27.         oledchine(16,0,1);
  28.         oledchar(40,0,'-',16);
  29.        
  30.         oledchar(72,0,'.',16);
  31.        
  32.         oledstr(88,0,"MHz-",16);
  33.         oledchine(0,2,2);
  34.         oledchine(16,2,3);
  35.         oledchar(64,2,'-',16);
  36.         oledchar(88,2,'-',16);
  37.        
  38.         while(1)
  39.         {
  40.         keynum=kpass();       
  41.                
  42.                 switch(keynum)
  43.                 {
  44.                         case 0:
  45.                                 break;
  46.                         case 1:
  47.                             rxfreq+=10;     //频率+
  48.                                 if(rxfreq>10800)
  49.                                 rxfreq=10800;
  50.                                 freqset(rxfreq);
  51.                                 break;
  52.                         case 2:
  53.                                 rxfreq-=10;    //频率-
  54.                                 if(rxfreq<8830)
  55.                                 rxfreq=8830;
  56.                                 freqset(rxfreq);
  57.                                 break;
  58.                         case 3:
  59.                                 vol+=1;       //音量+                               
  60.                                 if(vol>15)
  61.                                 vol=15;
  62.                                 volset(vol);  
  63.                                 break;
  64.                         case 4:
  65.                                 vol-=1;       //音量-
  66.                                 if(vol<1)
  67.                                 vol=1;
  68.                                 volset(vol);  
  69.                                 break;                               
  70.                 }       

  71.                     if(tn!=rxfreq|vol1!=vol)
  72.                 {
  73.                         tn=rxfreq;
  74.                         vol1=vol;
  75.                         xfreq=rxfreq/100;
  76.                         yfreq=rxfreq/10%10;
  77.                 olednum(72,2,vol,2,16);
  78.                 olednum(48,0,xfreq,3,16);
  79.                         olednum(80,0,yfreq,1,16);
  80.                 }
  81.                
  82.         }
  83. }
复制代 码



收藏 64 0 0