原帖由
i7
发自:dev.eefocus.com
------------------------------------------------------------------------------------------------------------------------------------------
一、UNO32和手机连接的照片如下: 将UNO32的串口1和手机的插座,用自制的数据线连接起来。 2、程序如下: (通过UNO32的串口1向手机发"ATD1368XXXXXXX;"命令,进行拨号)
// set pin numbers:
const int ledPin = 43; // the number of the LED pin
// Variables will change:
int ledState = LOW; // ledState used to set the LED
long previousMillis = 0; // will store last time LED was updated
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 10*1000; // interval at which to blink (milliseconds)
void setup() {
// set the digital pin as output:
pinMode(ledPin, OUTPUT);
Serial1.begin(9600);
}
void loop()
{
// here is where you'd put code that needs to be running all the time.
// check to see if it's time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
{
ledState = HIGH;
Serial1.println("ATD1368XXXXXXX;");
}
else
{
ledState = LOW;
Serial1.println("ATH");
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}
3、一点说明
(1)UNO32的输出是3.3V的,手机的输入也是3.3V的(超过这个电压,手机会关机),用UNO32和arduino相比,省去了电平转换的电路;
(2)使用串口1向手机发送命令,串口0用来升级程序或向电脑打印信息,方便调试程序;
(3)应用:可以在UNO32上接上若干传感器,比如温度、湿度、光线强度,达到预设的值后。自动拨打设定的号码,进行报警;此外也可以通过发短信的方式,传送更丰富的内容;
(4)手机数据线定义见此网址:http://pinouts.ru/CellularPhonesCables/siemens_dca-510_pinout.shtml
|