CC2530光敏控制LED灯亮灭 - IAR工程代码示例
#include 'ioCC2530.h'
#define D1 P1_0 #define GM P0_7
void Delay(unsigned int t) { while(t--); }
void main() { // 设置P1_0为输出,用于控制LED灯 P1DIR |= 0x01; // 设置P0_7为输入,用于读取光敏模块的输出 P0DIR &= ~0x80;
// 使能光敏模块 GM = 1;
while(1) { // 检测到弱光,点亮LED if(GM) { D1 = 1; } // 检测到强光,熄灭LED else { D1 = 0; } } }
原文地址: https://www.cveoy.top/t/topic/zVR 著作权归作者所有。请勿转载和采集!