gpio_set_level() can not set the output value of the PIN

Natsu_Kawa
Posts: 5
Joined: Tue Oct 23, 2018 2:50 am

gpio_set_level() can not set the output value of the PIN

Postby Natsu_Kawa » Mon Nov 05, 2018 12:20 pm

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 ..??

Natsu_Kawa
Posts: 5
Joined: Tue Oct 23, 2018 2:50 am

Re: gpio_set_level() can not set the output value of the PIN

Postby Natsu_Kawa » Tue Nov 06, 2018 1:32 am

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..?


Adham Aboud
Posts: 48
Joined: Mon Apr 30, 2018 5:32 pm

Re: gpio_set_level() can not set the output value of the PIN

Postby Adham Aboud » Tue Nov 06, 2018 6:55 am

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 ..??

Natsu_Kawa
Posts: 5
Joined: Tue Oct 23, 2018 2:50 am

Re: gpio_set_level() can not set the output value of the PIN

Postby Natsu_Kawa » Tue Nov 13, 2018 2:12 am

Adham Aboud wrote:
Tue Nov 06, 2018 6:55 am
You can't read the value of a GPIO if you didn't declare it as input....
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..?

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: gpio_set_level() can not set the output value of the PIN

Postby loboris » Tue Nov 13, 2018 8:40 am

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

Who is online

Users browsing this forum: Bing [Bot] and 127 guests