极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 21980|回复: 3

开源项目Arduino mini328连接TEA5767 收音机源码及电路

[复制链接]
发表于 2012-6-3 17:47:12 | 显示全部楼层 |阅读模式
转自:http://www.electronicsblog.net  

欢迎各位讨论及增加功能.....................................

手头上有一个TEA5767收音机电路 搜索了下网络 收集了相关教程 ,

还在了解代码,S1及S2是向上或向下搜台,由于接线太多.好象不太灵敏及噪音比较大,没有自搜保存电台功能?

用AD9.4画了个简单接线电路图, L R 须接功放放大音量

接线电路图在最下面.pdf

用arduino 0023  编写通过


手机3.7V电池,收听了3个小时运行正常,

新人 未知道怎么发代码,直接粘出来了~

源码:
  1. /// Arduino FM receiver with TEA5767
  2. #include <Wire.h>
  3. #include <LiquidCrystal.h>

  4. unsigned char search_mode=0;

  5. int b=0;
  6. int c=0;

  7. #define Button_next 6    //D6   
  8. #define Button_prev 7    //D7   

  9. unsigned char frequencyH=0;
  10. unsigned char frequencyL=0;

  11. unsigned int frequencyB;
  12. double frequency=0;

  13. double freq_available=0;

  14. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

  15. void setup()   {

  16.   Wire.begin();
  17.   lcd.begin(16, 2);

  18.   /// buttons  

  19.   pinMode(Button_next, INPUT);
  20.   digitalWrite(Button_next, HIGH); //pull up resistor

  21.   pinMode(Button_prev, INPUT);
  22.   digitalWrite(Button_prev, HIGH); //pull up resistor

  23.   frequency=87.5; //starting frequency

  24.   frequencyB=4*(frequency*1000000+225000)/32768; //calculating PLL word

  25.   frequencyH=frequencyB>>8;

  26.   frequencyL=frequencyB&0XFF;

  27.   delay(100);

  28.   Wire.beginTransmission(0x60);   //writing TEA5767

  29.   Wire.send(frequencyH);
  30.   Wire.send(frequencyL);
  31.   Wire.send(0xB0);
  32.   Wire.send(0x10);
  33.   Wire.send(0x00);
  34.   Wire.endTransmission();

  35.   delay(100);
  36. }

  37. void loop()
  38. {

  39.   unsigned char buffer[5];

  40.   lcd.setCursor(0, 0);

  41.   Wire.requestFrom(0x60,5); //reading TEA5767

  42.   if (Wire.available())

  43.   {
  44.     for (int i=0; i<5; i++) {

  45.       buffer[i]= Wire.receive();
  46.     }

  47.     freq_available=(((buffer[0]&0x3F)<<8)+buffer[1])*32768/4-225000;

  48.     lcd.print("FM ");

  49.     lcd.print((freq_available/1000000));

  50.     frequencyH=((buffer[0]&0x3F));

  51.     frequencyL=buffer[1];

  52.     if (search_mode) {

  53.       if(buffer[0]&0x80) search_mode=0;

  54.     }

  55.     if (search_mode==1) lcd.print(" SCAN");
  56.     else {
  57.       lcd.print("       ");
  58.     }

  59.     lcd.setCursor(0, 1);

  60.     lcd.print("Level: ");
  61.     lcd.print((buffer[3]>>4));
  62.     lcd.print("/16 ");

  63.     if (buffer[2]&0x80) lcd.print("STEREO   ");
  64.     else lcd.print("MONO   ");

  65.   }

  66.   ///// buttons read

  67.   //////////// button_next//////////
  68.   if (!digitalRead(Button_next)&&!b) {

  69.     frequency=(freq_available/1000000)+0.05;

  70.     frequencyB=4*(frequency*1000000+225000)/32768+1;

  71.     frequencyH=frequencyB>>8;
  72.     frequencyL=frequencyB&0XFF;   

  73.     Wire.beginTransmission(0x60);   

  74.     Wire.send(frequencyH);
  75.     Wire.send(frequencyL);
  76.     Wire.send(0xB0);
  77.     Wire.send(0x1F);
  78.     Wire.send(0x00);

  79.     Wire.endTransmission();

  80.     //////////////////////

  81.     b=100;

  82.   };

  83.   if (!digitalRead(Button_next)&&b==1) {

  84.     ///scannnn UP

  85.     search_mode=1;

  86.     Wire.beginTransmission(0x60);   

  87.     Wire.send(frequencyH+0x40);
  88.     Wire.send(frequencyL);
  89.     Wire.send(0xD0);
  90.     Wire.send(0x1F);
  91.     Wire.send(0x00);

  92.     Wire.endTransmission();

  93.     /////////////////

  94.     b=100;

  95.   };   

  96.   if (!b==0) b--;

  97.   //////////// button_prev//////////
  98.   if (!digitalRead(Button_prev)&&!c) {

  99.     frequency=(freq_available/1000000)-0.05;

  100.     frequencyB=4*(frequency*1000000+225000)/32768+1;

  101.     frequencyH=frequencyB>>8;
  102.     frequencyL=frequencyB&0XFF;

  103.     Wire.beginTransmission(0x60);   

  104.     Wire.send(frequencyH);
  105.     Wire.send(frequencyL);
  106.     Wire.send(0xB0);
  107.     Wire.send(0x1F);
  108.     Wire.send(0x00);

  109.     Wire.endTransmission();

  110.     c=100;

  111.   };

  112.   if (!digitalRead(Button_prev)&&c==1) {

  113.     ///scannnn DOWN

  114.     search_mode=1;

  115.     Wire.beginTransmission(0x60);   

  116.     Wire.send(frequencyH+0x40);
  117.     Wire.send(frequencyL);

  118.     Wire.send(0x50);
  119.     Wire.send(0x1F);
  120.     Wire.send(0x00);
  121.     Wire.endTransmission();   

  122.     c=100;

  123.   };         

  124.   if (!c==0) c--;

  125.   ////////////////////

  126. }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2012-6-3 21:27:52 | 显示全部楼层
支持,我之前在学校的时候也玩过一个,不错,继续努力!
回复 支持 反对

使用道具 举报

发表于 2012-6-3 22:36:43 | 显示全部楼层
好复杂的接线啊
回复 支持 反对

使用道具 举报

发表于 2013-1-1 20:00:10 | 显示全部楼层
想做了软件无线电设备。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-27 23:59 , Processed in 0.052876 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表