我正在尝试使用Adafruit 32u4 FONA制作一个简单的设备。只需按一下按钮,系统便会打开并拨打电话。但是出于某种原因,它拒绝打开电源并执行应做的事情。
void PinMode_Setup() {
pinMode(13, OUTPUT);//This is the blinky light
pinMode(6, OUTPUT);//This is the MOSFET gate
digitalWrite(6, HIGH);//Immediately activate the MOSFET gate
}
#include "OneButton.h"
#include "Adafruit_FONA.h"
#define FONA_RX 9
#define FONA_TX 8
#define FONA_RST 4
#define FONA_RI 7
#define Number "##########"
int count=0;//This will count how many times we blink before turning off
// Hardware serial is also possible!
HardwareSerial *fonaSerial = &Serial1;
// Use this for FONA 800 and 808s
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
uint8_t type;
void setup() {
digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW);
delay(1000); count++; if(count>2) {int count=0;} delay(2);
{
while (1);
}
type = fona.type();
switch (type) {
case FONA800L:
break;
case FONA800H:
break;
case FONA808_V1:
break;
case FONA808_V2:
break;
case FONA3G_A:
break;
case FONA3G_E:
break;
default:
break;
}
pinMode(FONA_RI, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
while (1) {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
uint8_t n = fona.getNetworkStatus();
if (n == 0) digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); count++; if(count>1) {int count=0;} delay(2); //Not registered
if (n == 1) digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); count++; if(count>2) {int count=0;} delay(2); //Registered (Online)
if (n == 2) digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); count++; if(count>3) {int count=0;} delay(2); //Not registered (searching)
if (n == 3) digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); count++; if(count>4) {int count=0;} delay(2); //Denied
if (n == 4) digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); count++; if(count>5) {int count=0;} delay(2); //Unknown
if (n == 5) digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); count++; if(count>6) {int count=0;} delay(2); //Registered roaming
if (n == 1) break;
}
Serial.println("Ready to contact!");
fona.playToolkitTone(1, 100);
delay(500);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
count++;
if(count>2)//After the third blink
{
Serial.print("Calling Phone");
fona.callPhone(Number);
}
}
这是我正在使用的简单电路。
顺便说一句,我正在使用3.7V 1200 mAh电池运行整个系统。
这是一个正常工作的示例代码。它会打开系统并闪烁5次,然后关闭。
int count=0;//This will count how many times we blink before turning off
void setup() {
pinMode(13, OUTPUT);//This is the blinky light
pinMode(6, OUTPUT);//This is the MOSFET gate
digitalWrite(6, HIGH);//Immediately activate the MOSFET gate
}
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
count++;
if(count>3)//After the fifth blink
{
digitalWrite(6, LOW);//Shut down the gate cutting off the power.
}
}
答案 0 :(得分:0)
我在这里看到几个问题。
1。。从原理图中,我看到您正在将按钮连接到引脚12,但未在代码中使用它。
2。。不需要MOSFET即可将I / O引脚拉高。
3。。面包板电源导轨需要并联连接,因为它们没有在引擎盖下(从字面上看)链接在一起。
请记住要向我们更新您的故障排除进度!