|
|
发表于 2015-4-11 21:54:22
|
显示全部楼层
正好今天在玩 pro micro 给你做了一下
pro micro 线出vcc 和 gnd 然后 人体释热传感器三个pin vcc gnd不用说,Out 接在pin14
然后我用的无源蜂鸣器(郁闷买错了,概念搞反了)
蜂鸣器 gnd vcc不用说,接在面包板上,然后i/o接在pin 14上
无源的稍微麻烦一点
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
This example code is in the public domain.
*/
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 10;
int buzz = 14;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
pinMode(buzz, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
Serial.println(buttonState);
if (HIGH==buttonState) {
for (int i=0;i<100; i++)
{
digitalWrite(buzz,HIGH);
delay(10);
digitalWrite(buzz,LOW);
delay(10);
}
}
else {delay(2000);}
}
|
|