板子回来了,这几天焊上了,今天发声了,但也有缺点就是发声的功放耗电在,用USB带会发出的声音不太好听,我用手机充电器的电源带,还可以.
以下是编译通过截图:
原程序如下:
-
- int CS_S = 4;
- int SCLK_S = 10;
- int MOSI_S = 9;
- int INT_S = 14;
- void setup()
- {
- pinMode(CS_S, OUTPUT); // sets the digital pin as output
- pinMode(SCLK_S, OUTPUT); // sets the digital pin as output
- pinMode(MOSI_S, OUTPUT); // sets the digital pin as output
- pinMode(INT_S, INPUT_PULLUP); // sets the digital pin as output
- // put your setup code here, to run once:
- digitalWrite(CS_S,HIGH);
- digitalWrite(SCLK_S,HIGH);
- digitalWrite(MOSI_S,HIGH);
-
- }
-
- void loop()
- {
- powerup();
- // put your main code here, to run repeatedly:
- while(1)
- {
- play(0);
- while(digitalRead(INT_S));
- }
- }
-
- void send8_S(unsigned char CHAR)
- {
- unsigned char i;
- unsigned char temp;
- digitalWrite(SCLK_S,LOW);
- digitalWrite(MOSI_S,LOW);
- for(i=0;i<8;i++)
- {
- digitalWrite(SCLK_S,LOW);
- temp =CHAR & 0x01;
- if(temp != 0)
- digitalWrite(MOSI_S,HIGH);
- else
- digitalWrite(MOSI_S,LOW);
- //delay(1);
- digitalWrite(SCLK_S,HIGH);
- //delay(1);
- CHAR >>=1;
- }
-
-
- }
-
- void powerup(void)
- {
- digitalWrite(CS_S,LOW);
- send8_S(0x00);
- send8_S(0x20);
- digitalWrite(CS_S,HIGH);
- }
-
- void play(unsigned char m)
- {
- digitalWrite(CS_S,LOW);
- send8_S(m*10);
- send8_S(0xE0);
- digitalWrite(CS_S,HIGH);
- digitalWrite(CS_S,LOW);
- send8_S(0x00);
- send8_S(0xF0);
- digitalWrite(SCLK_S,HIGH);
- }
再发个照片:
http://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr