[原创] 【TI首届低功耗设计大赛】让开发板说话

ddllxxrr   2014-11-20 16:08 楼主
板子回来了,这几天焊上了,今天发声了,但也有缺点就是发声的功放耗电在,用USB带会发出的声音不太好听,我用手机充电器的电源带,还可以. 以下是编译通过截图: en.JPG 原程序如下:
  1. <P> </P>
  1. int CS_S = 4;
  2. int SCLK_S = 10;
  3. int MOSI_S = 9;
  4. int INT_S = 14;
  5. void setup()
  6. {
  7. pinMode(CS_S, OUTPUT); // sets the digital pin as output
  8. pinMode(SCLK_S, OUTPUT); // sets the digital pin as output
  9. pinMode(MOSI_S, OUTPUT); // sets the digital pin as output
  10. pinMode(INT_S, INPUT_PULLUP); // sets the digital pin as output
  11. // put your setup code here, to run once:
  12. digitalWrite(CS_S,HIGH);
  13. digitalWrite(SCLK_S,HIGH);
  14. digitalWrite(MOSI_S,HIGH);
  15. }
  16. void loop()
  17. {
  18. powerup();
  19. // put your main code here, to run repeatedly:
  20. while(1)
  21. {
  22. play(0);
  23. while(digitalRead(INT_S));
  24. }
  25. }
  26. void send8_S(unsigned char CHAR)
  27. {
  28. unsigned char i;
  29. unsigned char temp;
  30. digitalWrite(SCLK_S,LOW);
  31. digitalWrite(MOSI_S,LOW);
  32. for(i=0;i<8;i++)
  33. {
  34. digitalWrite(SCLK_S,LOW);
  35. temp =CHAR & 0x01;
  36. if(temp != 0)
  37. digitalWrite(MOSI_S,HIGH);
  38. else
  39. digitalWrite(MOSI_S,LOW);
  40. //delay(1);
  41. digitalWrite(SCLK_S,HIGH);
  42. //delay(1);
  43. CHAR >>=1;
  44. }
  45. }
  46. void powerup(void)
  47. {
  48. digitalWrite(CS_S,LOW);
  49. send8_S(0x00);
  50. send8_S(0x20);
  51. digitalWrite(CS_S,HIGH);
  52. }
  53. void play(unsigned char m)
  54. {
  55. digitalWrite(CS_S,LOW);
  56. send8_S(m*10);
  57. send8_S(0xE0);
  58. digitalWrite(CS_S,HIGH);
  59. digitalWrite(CS_S,LOW);
  60. send8_S(0x00);
  61. send8_S(0xF0);
  62. digitalWrite(SCLK_S,HIGH);
  63. }
再发个照片: 照片 044.jpg
http://shop34182318.taobao.com/ https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr

回复评论 (3)

牛X,居然还用笔写程序草稿!
点赞  2014-11-20 16:13
板,来给哥唱个小曲儿。期待更多资料。
点赞  2014-11-20 16:24
引用: lcofjp 发表于 2014-11-20 16:13
牛X,居然还用笔写程序草稿!

刚发现,还真是
点赞  2014-11-20 16:37
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复