rpi shutdown switch question

Support for connecting hardware to the Raspberry Pi GPIO

Moderators: russ, Ralph

Post Reply
Message
Author
Utingbato
Posts: 12
Joined: Fri Jun 24, 2016 3:01 pm

rpi shutdown switch question

#1 Post by Utingbato »

hi to all,

i want to ask if this code is correct?

Code: Select all

-- Callback function which is called when the button is pressed
function shutdown()
  -- Shut down Windows or the Raspberry Pi
shut_down("SYSTEM")
end

hw_button_add("RPI_V2_P1_36", shutdown)
I want to put dedicated switch to shutdown the RPI.

Thank you

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: rpi shutdown switch question

#2 Post by SimPassion »

No problem with this @Utingbato
if any issue rename the function like this or anything else (I don't know if shutdown is an internal reserved word)

Code: Select all

function computer_shutdown()
Gilles

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: rpi shutdown switch question

#3 Post by Sling »

Looks ok @Utingbato. Have you tried it?

Utingbato
Posts: 12
Joined: Fri Jun 24, 2016 3:01 pm

Re: rpi shutdown switch question

#4 Post by Utingbato »

SimPassion wrote: Wed Oct 09, 2019 6:45 am No problem with this @Utingbato
if any issue rename the function like this or anything else (I don't know if shutdown is an internal reserved word)

Code: Select all

function computer_shutdown()
Gilles
I just saw i here in wiki.
https://siminnovations.com/wiki/index.p ... =Shut_down

Looks ok @Utingbato. Have you tried i
Yes but no response from RPI. in short nothing happens. i also tried from other pins and same result.


Thank you

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: rpi shutdown switch question

#5 Post by Sling »

Is the instrument this code is part of loaded to the Rpi and is the instrument running when you press the shutdown button.

Utingbato
Posts: 12
Joined: Fri Jun 24, 2016 3:01 pm

Re: rpi shutdown switch question

#6 Post by Utingbato »

Sling wrote: Thu Oct 10, 2019 3:00 am Is the instrument this code is part of loaded to the Rpi and is the instrument running when you press the shutdown button.
Yes its loaded to the instrument and running with the same instrument in rpi.

User avatar
Ralph
Posts: 7867
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: rpi shutdown switch question

#7 Post by Ralph »

Your first step would be to put a print in your function and see if it really triggers the function when you press the button. Then you know that it is not hardware related.

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: rpi shutdown switch question

#8 Post by Sling »

Ralph wrote: Thu Oct 10, 2019 6:52 am Your first step would be to put a print in your function and see if it really triggers the function when you press the button. Then you know that it is not hardware related.
If you want to do a similar thing but while running on the Rpi you could use visible to show or hide any image in response to the button press and release. I'd try the print as Ralph suggests first though. You will need to run in Create/Edit to see the print result.

Utingbato
Posts: 12
Joined: Fri Jun 24, 2016 3:01 pm

Re: rpi shutdown switch question

#9 Post by Utingbato »

Ralph wrote: Thu Oct 10, 2019 6:52 am Your first step would be to put a print in your function and see if it really triggers the function when you press the button. Then you know that it is not hardware related.
ok i'll try. then report back.
If you want to do a similar thing but while running on the Rpi you could use visible to show or hide any image in response to the button press and release. I'd try the print as Ralph suggests first though. You will need to run in Create/Edit to see the print result.
Thank you so much.

Utingbato
Posts: 12
Joined: Fri Jun 24, 2016 3:01 pm

Re: rpi shutdown switch question

#10 Post by Utingbato »

all working now. thank you so much

Post Reply