rpi shutdown switch question

Support for connecting hardware to the Raspberry Pi GPIO

Moderators: Ralph, russ

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

rpi shutdown switch question

#1 Post by Utingbato » Wed Oct 09, 2019 6:17 am

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: 3542
Joined: Thu Jul 27, 2017 12:22 am

Re: rpi shutdown switch question

#2 Post by SimPassion » 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

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

Re: rpi shutdown switch question

#3 Post by Sling » Wed Oct 09, 2019 6:57 am

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 » Thu Oct 10, 2019 12:32 am

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: 4385
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: rpi shutdown switch question

#5 Post by Sling » 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.

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

Re: rpi shutdown switch question

#6 Post by Utingbato » Thu Oct 10, 2019 5:54 am

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: 4912
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: rpi shutdown switch question

#7 Post by Ralph » 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.

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

Re: rpi shutdown switch question

#8 Post by Sling » Thu Oct 10, 2019 8:49 am

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 » Fri Oct 11, 2019 2:29 am

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 » Fri Oct 25, 2019 9:27 am

all working now. thank you so much

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest