前言
一、代码及编译
1.代码
#include <stdio.h>
#include <unistd.h>
#include "ohos_init.h"
#include "cmsis_os2.h"
#include "wifiiot_gpio.h"
#include "wifiiot_gpio_ex.h"
#include "wifiiot_adc.h"
#define PHOTO_SENSOR_CHAN_NAME WIFI_IOT_ADC_CHANNEL_4
unsigned short data = 0;
static void HummanSensorLightTask(void *arg)
{
(void)arg;
WifiIotGpioValue rel = 0;
while (1)
{
GpioGetInputVal(WIFI_IOT_IO_NAME_GPIO_7, &rel) ;
AdcRead(PHOTO_SENSOR_CHAN_NAME, &data, WIFI_IOT_ADC_EQU_MODEL_4, WIFI_IOT_ADC_CUR_BAIS_DEFAULT, 0);
if((int)data>1800)
{
GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_10, (int)rel);
GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_11, (int)rel);
GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_12, (int)rel);
usleep(20