I write a callback func like this to deive my peripheral , it runs when a specific key is down:
void DrainWater(void)
{
gpio_set_level(GPIO_NUM_x,1);//set the pin as high level to drive the peripheral
printf("The Value Of The GPIO_NUM_x now is %d",gpio_get_level(GPIO_NUM_x));
}
this func is included in a Task created in main.h
build and no error or warring...
but when I open my port assisstant , screan print
The Value Of The GPIO_NUM_x now is 0
can anybody help me ...?
thanks in advance...its so strange a question isn it ..??
gpio_set_level() can not set the output value of the PIN
-
- Posts: 5
- Joined: Tue Oct 23, 2018 2:50 am
-
- Posts: 5
- Joined: Tue Oct 23, 2018 2:50 am
Re: gpio_set_level() can not set the output value of the PIN
Ok guys ... there actually has not such a question here .. bucause when I use avometer to check the value of the pin , the pin was actually on the high value while the the msg printf by gpio_get_level(); is "0" , so there is also sth wrong on API..?
-
- Posts: 48
- Joined: Mon Apr 30, 2018 5:32 pm
Re: gpio_set_level() can not set the output value of the PIN
You can't read the value of a GPIO if you didn't declare it as input....
Natsu_Kawa wrote:I write a callback func like this to deive my peripheral , it runs when a specific key is down:
void DrainWater(void)
{
gpio_set_level(GPIO_NUM_x,1);//set the pin as high level to drive the peripheral
printf("The Value Of The GPIO_NUM_x now is %d",gpio_get_level(GPIO_NUM_x));
}
this func is included in a Task created in main.h
build and no error or warring...
but when I open my port assisstant , screan print
The Value Of The GPIO_NUM_x now is 0
can anybody help me ...?
thanks in advance...its so strange a question isn it ..??
-
- Posts: 5
- Joined: Tue Oct 23, 2018 2:50 am
Re: gpio_set_level() can not set the output value of the PIN
well , i actually had decleared the pin as input mode before I call the func gpio_get_level(),but I cannot see the change of the pin on my screan still... but when I use avometer to check the level of the pin ,it does changed while it just didn't show on my screan...its so strange isn't it..?Adham Aboud wrote: ↑Tue Nov 06, 2018 6:55 amYou can't read the value of a GPIO if you didn't declare it as input....
Re: gpio_set_level() can not set the output value of the PIN
Think about which mode you have to set to use the pin as output and be able to read its value back.
https://docs.espressif.com/projects/esp ... pio_mode_t
https://docs.espressif.com/projects/esp ... pio_mode_t
Who is online
Users browsing this forum: Baidu [Spider], Reenis and 110 guests