本帖最后由 pcduino 于 2013-4-11 14:08 编辑
前些时候发过pcDuino运行GPRS shield 打电话的例程,那个帖子中主要是图片展示,为了更好的让新手能够也动手操作,现在补充一点介绍以及注意事项哈
编译成功后拨个电话试试,注意打电话时还是要用到SIM卡和 microphone
再附上代码:
- #include
- #include “Serial.h”
- #define key1 8
- #define key2 9
- #define led 10
- void port_init()
- {
- pinMode(key1,INPUT);
- pinMode(key2,INPUT);
- pinMode(led,OUTPUT);
- }
- void wait()
- {
- digitalWrite(led,LOW);
- delay(200);
- digitalWrite(led,HIGH);
- delay(200);
- }
- void setup()
- {
- //Initialize serial and wait for port to open:
- int rate = 19200;
- Serial.begin(rate);
- while (!Serial)
- {
- ; // wait for serial port to connect. Needed for Leonardo only
- }
- port_init();
- delay(500);
- }
- void loop()
- {
- int value1 = digitalRead(key1);
- int value2 = digitalRead(key2);
- wait();
- if(value1)
- {
- delay(10);
- value1 = digitalRead(key1);
- if(value1)
- {
- Serial.println(“ATD + +1720XXXXXXX;”);//dial the number
- digitalWrite(led,HIGH);
- do{
- value2 = digitalRead(key2);
- if(value2)
- {
- delay(10);
- value2 = digitalRead(key2);
- }
- }while(!value2);
- Serial.println(“ATD + ATH”);
- digitalWrite(led,LOW);
- delay(500);
- while(1);
- }
- }
- }
复制代码
|