【发布时间】:2020-12-30 21:23:32
【问题描述】:
我正在尝试创建的项目是一个电压断路器电路;它本质上是通过使用传感器来测量电路的电压,如果超过用户选择的电压使用电位计,它会通过继电器切断电路其余部分的电源:全部由 Arduino 供电和处理。
我已经让电路与 LCD 一起工作,但是它有点笨重,并且没有必要用 lcd 来表示两位数,所以我寻找了一个替代方案。
目的是用一个四位八段显示器和一个移位寄存器来代替它(我已经用完了 Arduino Nano 上的 GPIO 引脚)但是我似乎做不到。
代码如下:
#include <SevSegShift.h>
const int SHIFT_PIN_DS = 8; /* Data input PIN */
const int SHIFT_PIN_STCP = 7; /* Shift Register Storage PIN */
const int SHIFT_PIN_SHCP = 6; /* Shift Register Shift PIN */
//Instantiate a seven segment controller object (with Shift Register functionality)
SevSegShift sevsegshift(
SHIFT_PIN_DS,
SHIFT_PIN_SHCP,
SHIFT_PIN_STCP,
1, /* number of shift registers there is only 1 Shiftregister
used for all Segments (digits are on Controller)
default value = 2 (see SevSegShift example)
*/
true /* Digits are connected to Arduino directly
default value = false (see SevSegShift example)
*/
);
void setup() {
byte numDigits = 4;
byte digitPins[] = {5, 4, 3, 2}; // These are the PINS of the ** Arduino **
byte segmentPins[] = {0, 2, 4, 6, 7, 1, 3, 5}; // these are the PINs of the ** Shift register **
bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
byte hardwareConfig = COMMON_CATHODE; // See README.md for options
bool updateWithDelays = false; // Default 'false' is Recommended
bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
bool disableDecPoint = false; // Use 'true' if your decimal point doesn't exist or isn't connected. Then, you only need to specify 7 segmentPins[]
SevSeg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, leadingZeros, disableDecPoint);
}
我不断收到的错误是:
退出状态 1 '.' 之前的预期不合格 ID令牌
突出显示的行是:
SevSeg.begin(hardwareConfig、numDigits、digitPins、segmentPins、resistorsOnSegments、updateWithDelays、leadingZeros、disableDecPoint);
有谁知道这可能意味着什么?
感谢您的帮助!
【问题讨论】:
标签: arduino