--- /dev/null
+int fmpin=12; //设置蜂鸣器数字接口1
+void setup()
+{
+ pinMode(fmpin,OUTPUT);
+}
+
+void fm(float f)
+{
+ float T = (float) ((float)1000000) / f;
+
+ int d = (int) (T/2);
+
+ int cnt = 1*(int)f;
+
+ int i;
+ for(i=0; i<cnt; ++i)
+ {
+ digitalWrite(fmpin,HIGH); //产生1KHz的脉冲
+ delayMicroseconds(d);
+ digitalWrite(fmpin,LOW);
+ delayMicroseconds(d);
+ }
+
+ delay(200);
+}
+
+void loop()
+{
+ fm(2560);
+ fm(2880);
+ fm(3200);
+ fm(3413.33);
+ fm(3840);
+ fm(4266.67);
+ fm(4800);
+ fm(5120);
+ fm(5120);
+}
--- /dev/null
+
+const int ledPin = 12;
+int cnt = 0;
+
+void setup() {
+ Serial.begin(9600);
+ pinMode(ledPin, OUTPUT);
+}
+
+void loop() {
+ cnt ++;
+
+ int lv = analogRead(0); // Light
+
+ int tv = analogRead(1); // Temperature
+
+ delay(100);
+
+ float temperature;
+ float resistance = (float)(1023-tv)*10000/tv;
+ temperature = 1/(log(resistance/10000)/3975+1/298.15) - 273.15;
+ if(cnt % 10 == 0)
+ {
+ Serial.print("Light Sensor Value: ");
+ Serial.println(lv);
+
+ Serial.print("Temperature Sensor Value: ");
+ Serial.println(tv);
+
+ Serial.print("Temperature: ");
+ Serial.println(temperature);
+ }
+
+ if(lv < 400)
+ {
+ digitalWrite(ledPin, HIGH);
+ }
+ else
+ {
+ digitalWrite(ledPin, LOW);
+ }
+
+}
--- /dev/null
+/*
+* 发射红外线信号
+* 注意! 红外线发射器(IR LED)必须接到 pin 3, 不能接其它脚位
+
+ Hisense 机顶盒 SD-16127 tested
+ */
+
+//By Leo 2013.02.19
+//http://weibo.com/leolite
+//Update: Pin 3 IR LED test function
+
+
+#include <IRremote.h> // 引用 IRRemote 函式库
+
+int RECV_PIN = 11;
+IRrecv irrecv(RECV_PIN);
+
+IRsend irsend; // 定义 IRsend 物件来发射红外线讯号
+decode_results results;
+
+
+void setup()
+{
+ Serial.begin(9600);
+ pinMode(3,OUTPUT);
+ /*
+ irrecv.enableIRIn();
+
+ pinMode(3, OUTPUT);
+ digitalWrite(3, HIGH); // 点亮LED测试(需通过手机摄像模式观察)
+ delay(3000); // 等待3秒
+ digitalWrite(3, LOW); // 结束测试*/
+}
+
+void showIRProtocol(decode_results *results)
+{
+ Serial.print("Protocol: ");
+
+ // 判断红外线协定种类
+ switch(results->decode_type) {
+ case NEC:
+ Serial.print("NEC");
+ break;
+ case SONY:
+ Serial.print("SONY");
+ break;
+ case RC5:
+ Serial.print("RC5");
+ break;
+ case RC6:
+ Serial.print("RC6");
+ break;
+ default:
+ Serial.print("Unknown encoding");
+ }
+
+ // 把红外线编码印到 Serial port
+ Serial.print(", irCode: ");
+ Serial.print(results->value, HEX); // 红外线编码
+ Serial.print(", bits: ");
+ Serial.println(results->bits); // 红外线编码位元数
+}
+
+void loop()
+{
+ //Serial.print("SendIR: ");
+ //irsend.sendNEC(0x807FE01F, 32); // 记得换成你遥控器的红外线编码
+ //delay(100); // 等待3秒
+
+ if(irrecv.decode(&results)) {
+ //Serial.println(results.value, HEX);
+ //Serial.println();
+ showIRProtocol(&results);
+ irrecv.resume();
+ }
+}
+