关于Arduino UNO软复位后的问题提问

在使用Arduino UNO进行软复位后,遇到了意外的异常复位情况。在检查代码后,发现可能问题存在于.laser.h、.laser.cpp及.ino文件中。寻求帮助以找出导致此问题的具体原因。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

对于Arduino,可以用

void(* resetFunc)(void) = 0;
......
resetFunc();

进行软复位。

但是,本人的UNO进行过这一操作后出现异常复位的现象。

laser.h如下:

#include "Arduino.h"
#include <RobotIRremote.h>
#include <RobotIRremoteInt.h>
#define pi 3.14
#define ir1 16738455
#define ir2 16750695
#define ir3 16756815
#define ir4 16724175
#define ir5 16718055
#define ir6 16743045
#define ir7 16716015
#define ir8 16726215
#define ir9 16734885
#define ir0 16730805
#define irj 16732845
#define irx 16728765
#define longpress 4294967295
#define irok 16712445
#define left 16720605
#define right 16761405
#define down 16754775
#define up 16736925
using namespace std;

void laserSet(int,int,int);
void trans(float fa[], short int si[]);
void circle(short int x[], short int y[], float r);
void ellipse(short int x[], short int y[], float a, float b);
void heart(short x[], short y[], float a);
float serialIn(const char*);
void constout(short a[], short b[]);
void zoomout(short a[], short b[], float c);
void rotout(short a[], short b[], float c);
void rzout(short a[], short b[], float c, float d);
char irmode(int);
float irin(int,const char*);
short shape(const char* instream, int pin);
void t_ellipse(const char* instream, int pin, short x[], short y[]);
void t_circle(const char* instream, int pin, short x[], short y[]);
void t_heart(const char* instream, int pin, short x[], short y[]);

laser.cpp如下:

#include "laser.h"
void laserSet(int xpin,int ypin,int kpin) {
  TCCR1B = TCCR1B & 0b11111000 | 1;//调整系统时钟
  pinMode(xpin, OUTPUT);//x 连9
  pinMode(ypin, OUTPUT);//y 连10
  pinMode(kpin, OUTPUT); //laser on/off,连4
  pinMode(13, OUTPUT);
  digitalWrite(kpin, LOW);//关闭激光输出
  digitalWrite(13, LOW);
  Serial.begin(115200);
  while (Serial.read() > 0);
}

void trans(float fa[], short int si[]) {//将浮点数据转为整形(0-255)
  for (int i = 0; i < 9
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值