自从入手arduinon差不多半个月了,在window下几乎没有任何问题,下载,编程,编译,上传,运行。几乎没有任何问题。在linux编译成功,上传时下却总是提示找不到libncurses.so.5无法载入等错误信息,经过各种查找资料,终于搞定了。步骤如下:
(1)首先,由于我的系统永远是最新的,libncurses是6.0版本的,要找到libncures5版本的,终于在一台较老的chakra linux中找到了;分别拷贝到/usr/lib/和/usr/lib32/目录中,其中lib和lib64是一样的,lib32的32位的库目录
(2)接着,创建连接文件
cd /usr/lib/
ln -s libncurses.so.5 libtinfo.so.5
cd ../lib32/
ln -s libncurses.so.5 libtinfo.so.5
(3)最后就可以编译成功了。下面分享一个西游记中女儿情的程序:
软件部分:
#define NOTE_D0 -1
#define NOTE_D1 350
#define NOTE_D2 393
#define NOTE_D3 441
#define NOTE_D4 495
#define NOTE_D5 556
#define NOTE_D6 624
#define NOTE_D7 661
#define NOTE_DL1 175
#define NOTE_DL2 196
#define NOTE_DL3 221
#define NOTE_DL4 234
#define NOTE_DL5 262
#define NOTE_DL6 294
#define NOTE_DL7 330
#define NOTE_DH1 700
#define NOTE_DH2 786
#define NOTE_DH3 882
#define NOTE_DH4 935
#define NOTE_DH5 1049
#define NOTE_DH6 1178
#define NOTE_DH7 1322
#define WHOLE 1
#define HALF 0.5
#define QUARTER 0.25
#define EIGHTH 0.125
#define SIXTEENTH 0.0625
int tune[] = {
NOTE_D0,NOTE_DL5,NOTE_DL6,NOTE_D1,NOTE_D2,NOTE_D3,NOTE_DL7,NOTE_DL6,NOTE_DL7,NOTE_DL5,NOTE_DL6,
//1,0.5,0.5,1.5,0.5,0.75,0.25,0.25,0.25,0.5,2,
NOTE_DL6,NOTE_D1,NOTE_D2,NOTE_D3,NOTE_D5,NOTE_D6,NOTE_D1,NOTE_D2,NOTE_D3,NOTE_D4,NOTE_D3,
//1,0.5,0.5,1.5,0.5,0.5,0.5,0.25,0.25,0.5,2,
NOTE_D3,NOTE_D3,NOTE_D5,NOTE_D6,NOTE_D5,NOTE_D6,NOTE_DL6,NOT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0.5,0.5,1.5,0.5,1,1,1.5,0.5,0.5,1,0.5,0.5,1.5,2,
0.5,0.5,0.5,0.5,0.5,1,0.25,0.25,2,2,
0.5,0.5,0.5,0.5,0.5,1,0.25,0.25,2,
1,0.5,0.5,1.5,0.5,0.75,0.25,0.25,0.25,0.5,2,
1,0.5,0.5,1.5,0.5,0.5,0.5,0.25,0.25,0.5,2,
1,0.5,0.5,1.5,0.5,1,0.5,0.5,1.5,0.5,
1,1,1.5,0.5,0.5,1,0.5,0.5,1.5,2,
};
int length;
int tonePin = 5;
void setup() {
// put your setup code here, to run once:
pinMode(tonePin, OUTPUT);
length = sizeof(tune) / sizeof(tune[0]);
}
硬件连接非常简单,只要将数字接口5连接到喇叭的正,喇叭的负接地即可。