lock_ctrl/main.cpp

24 lines
458 B
C++
Raw Permalink Normal View History

2025-06-05 16:36:58 +08:00
#include "GPIOControl.h"
#include <thread>
#include <chrono>
int main()
{
GPIOControl relay(42); // 继电器接在 GPIO42
if (!relay.exportGPIO())
return 1;
usleep(100000); // 确保 sysfs 完全准备好
if (!relay.setDirection("out"))
return 1;
// 打开继电器
relay.setValue(true);
std::this_thread::sleep_for(std::chrono::seconds(2));
// 关闭继电器
relay.setValue(false);
return 0;
}