arduino uno r3 + SIM900 + USB打火机 实现电话触发点火
需求来源
1.儿子过完年6岁,喜欢玩烟花,但是胆子小,于是我就负责点火,从年前26到大年初八,每天晚上要给儿子点鞭炮啊点鞭炮。
2.这边过年要打关门炮跟开门炮,大年初一凌晨还要起来帮老妈点鞭炮,说实在的那个整串的小鞭炮也炸的太快了,每次没跑几步就开响,哥也心脏不好啊。
设计:
根据需求,我们需要个远程点火的打火机,上taobao上逛了一圈,找到了usb打火机,续电器,外加一张SIM900 arduino扩展板,回来简单的一连,就了了了。
代码:
#include <SoftwareSerial.h>
#include <String.h> SoftwareSerial GPRS(, );
String currentLine = ""; // string to hold the text from server
String triggerNo="";
String mobile = "";
boolean readingNo=false;
long lastTriggerTime=;
boolean fireing=false;
int led=;
void setup()
{
GPRS.begin(); // the GPRS baud rate
Serial.begin(); // the GPRS baud rate
pinMode(, OUTPUT);
pinMode(led,OUTPUT);
digitalWrite(led,LOW);
delay();
powerUpOrDown();
}
void loop()
{
if(fireing){
if( millis() - lastTriggerTime >= * ){
Serial.println("stop fire!");
digitalWrite(led,LOW);
fireing=false;
}else{
return;
}
} while(GPRS.available()){
char inChar=GPRS.read();
currentLine +=inChar; if(inChar=='\n')currentLine=""; if(currentLine.endsWith( "+CLIP: \"")){
readingNo=true;
mobile="";
} if(readingNo){ if(inChar !=','){
if(inChar !='"')mobile+=inChar;
}else{
readingNo=false;
Serial.println(mobile);
if(mobile==triggerNo){
lastTriggerTime=millis();
Serial.println("fire!!");
fireing=true; currentLine="";
mobile="";
delay();
digitalWrite(led,HIGH);
delay(); GPRS.println("ATH");
while(GPRS.available()){
GPRS.read();
} } }
}
}
} void powerUpOrDown()
{ digitalWrite(,LOW);
delay();
digitalWrite(,HIGH);
delay();
digitalWrite(,LOW);
delay();
}
效果图(分待机状态跟触发状态):


#include <SoftwareSerial.h>
#include <String.h> SoftwareSerial GPRS(, );
String currentLine = ""; // string to hold the text from server
String triggerNo="";
String mobile = "";
boolean readingNo=false;
long lastTriggerTime=;
boolean fireing=false;
int led=;
long lastReadTime=;
void setup()
{
GPRS.begin(); // the GPRS baud rate
Serial.begin(); // the GPRS baud rate
pinMode(, OUTPUT);
pinMode(led,OUTPUT);
digitalWrite(led,LOW);
delay(); }
void loop()
{
if(fireing){
if( millis() - lastTriggerTime >= * ){
Serial.println("stop fire!");
digitalWrite(led,LOW);
fireing=false;
}else{
return;
}
} while(GPRS.available()){
lastReadTime=millis(); char inChar=GPRS.read();
currentLine +=inChar; if(inChar=='\n')currentLine=""; if(currentLine.endsWith( "+CLIP: \"")){
readingNo=true;
mobile="";
} if(readingNo){ if(inChar !=','){
if(inChar !='"')mobile+=inChar;
}else{
readingNo=false;
Serial.println(mobile);
if(mobile==triggerNo){
lastTriggerTime=millis();
Serial.println("fire!!");
fireing=true; currentLine="";
mobile="";
delay();
digitalWrite(led,HIGH);
delay(); GPRS.println("ATH");
while(GPRS.available()){
GPRS.read();
} } }
}
} if(millis()- lastReadTime >= * )
{
tryPowerUp();
}
}
void tryPowerUp(){
GPRS.println("AT");
delay();
if(GPRS.available())return; powerUpOrDown();
}
void powerUpOrDown()
{ digitalWrite(,LOW);
delay();
digitalWrite(,HIGH);
delay();
digitalWrite(,LOW);
delay();
}
arduino uno r3 + SIM900 + USB打火机 实现电话触发点火的更多相关文章
- Arduino UNO R3
Arduino 常见型号 当然还有 LilyPad,附图: 最常见的自然是UNO,最新版是第三版R3: 国内也有一些改进的板子.我用的是一般的板子,拿到货也只能默默了. 简介 The Uno is a ...
- Arduino uno R3 ISP刷Rootloader for arduino pro mini
找了好久才发现的,好东西.介绍怎么使用uno对mini 刷Rootloader **SOLUTION** Reinstall the Arduino Pro Mini Bootloader using ...
- [Arduino] Arduino Uno R3 中文介绍
Arduino UNO是Arduino USB接口系列的最新版本,作为Arduino平台的参考标准模板.UNO的处理器核心是ATmega328,同时具有14路数字输入/输出口(其中6路可作为PWM输出 ...
- Arduino uno r3 使用 ESP8266 UART-WiFi 透传模块
一.所需硬件材料 1.ESP8266:01s某宝上3.5块钱 2.杜邦线:某宝几块钱一组40P,这里只需要三根,用于连接 树莓派与继电器 3.烧录器 二.ESP8266 AT固件烧录 ESP8266主 ...
- 基于arduino UNO R3+ESP8266控制LED灯的开关(无USB转TTL工具实现)
最近由于项目要求,需要开发物联网云平台,而本人对硬件和通信技术一窍不通,故而选择arduino这一简单单片机来实现学习掌握基础的硬件和通信技术. 下面就是本人通过查阅大佬资料做的一个整合版本的通过手机 ...
- Ubuntu16.04 Arduino UNO R3开发板
使用的是国内改过的版本, usb芯片换成了ch341, 晶振不是原版的16MHz而是12MHz, 杜邦线孔布局和原版一致. 设备连接 在Ubuntu16.04下不需要驱动, 能直接认出ch341设备 ...
- 订购一套Arduino UNO r3入门套件
若需要arduino套件经济版请点击以下链接跳转: http://item.taobao.com/item.htm?id=36759198826 这就开始了吗?希望有所收获吧-!
- Arduino入门套件 Arduino UNO R3
限时大抢购:原价5.6元超声波模块HC-SR04,现只需3元,亏本大甩卖,只赚人气,如需购买的客户请直接拍下以下链接3件=3元购买,备注超声波模块即可,每个客户ID每天仅限购一个.http://det ...
- arduino uno r3的数据类型
char 一个字节,存储一个字符值.字符文字用单引号写成:'A' unsigned char 无符号,一个字节 byte 一个字节,无符号数, int 2字节,这产生-32768至32767的范围. ...
随机推荐
- WDA-FPM-2-APPLICATION-TABSTRIP(OIF)
转载:https://www.cnblogs.com/sapSB/p/10081344.html FPM二:简单的APPLICATION-TABSTRIP(OIF) 1.新建WDA程序ZLYFPM ...
- Json字符串转Dictionary
/// <summary> /// json字符串转Dictionary /// </summary> /// <param name="json"& ...
- Shell常用命令find、grep总结
一.find 命令 find 命令的常用形式可以简化为 find [path...][expression] path:find 命令查找的目录路径,其中 ./ 表示当前目录,/ 表示系统根目录 ex ...
- 转载:canal数据库同步redis
ref: http://blog.csdn.net/tb3039450/article/details/53928351
- python限制函数执行时间
from:https://stackoverflow.com/questions/366682/how-to-limit-execution-time-of-a-function-call-in-py ...
- python classmethod 和 staticmethod的区别
https://stackoverflow.com/questions/12179271/meaning-of-classmethod-and-staticmethod-for-beginner 1. ...
- GIS on CentOS 7 之 PostgreSQL & PostGIS
PostgreSQL & PostGIS 安装postgresql 配置好yum源之后,使用yum info postgresql可发现 postgresql的版本为9.2.23,若想安装最新 ...
- 进化的Spark, 从DataFrame说起
进化的Spark, 从DataFrame说起:http://www.tuicool.com/articles/IzeY7zM
- Java.sql.SQLException: 无效的列类型: 1111
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: ...
- leetcode 196. Delete Duplicate Emails
# 慢,内连接delete p1 from Person p1, Person p2 where p1.Email=p2.Email and p1.Id>p2.Id delete from Pe ...