OK, here's my progress report:
I tried the reference and script I found here:
https://www.element14.com/community/doc ... berry-pi-b
The author has you make a Scripts directory, then write the little Python script. After that, he has you add it to the list of programs to run on start-up.
Code: Select all
# Simple script for shutting down the RPi at the press of a button.
# by Inderpreet Singh - Edited by Val Barlow
import RPi.GPIO as GPIO
# Use the Broadcom SOC Pin numbers
# Setup the Pin with Internal pullups enabled and PIN in reading mode.
GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_UP)
# Our function on what to do when the button is pressed.
os.system("sudo shutdown -h now")
# Add our function to execute when the button is pressed.
GPIO.add_event_detect(18, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
# Now Wait!
Not too complicated, there.
It references GPIO 18 (pin 12) and the Ground connection (pin 14)
I followed the instructions, saved off the files, shutdown the Pi, connected the pins accordingly, started things back up, and...
After it boots up completely, I press the button.
After a short pause, it shuts down!
Now, all I need to do, is get the LED on the switch to work...
I reference https://howchoo.com/g/ytzjyzy4m2e/build ... -indicator
So, into the /boot/config.txt file I go (to add enable_uart=1
Save off the file and shut down.
OK, now I connect my circuit to the following pins:
Pin 6 - GND (Resistor to Negative pole of the LED)
Pin 8 - GPIO14 [TXD] (Positive pole of the LED)
Now it's time to cross my fingers and boot up.
The test LED lights up accordingly!
So, all in all, a Great Success!
To be fair, I had to debug my script, as I had a couple of typos in it
and we all know just how finicky Linux Code can be, so I had to fix those to get it to work.
There are a few pics I took of my little project, but I am unsure of how to get those posted here without going over the size limits, or getting myself in trouble, so I'll just give credit where it's due here:
To pcmanbob and alphanumeric: Thanks for the quick replies and encouraging posts!
The authors of the articles I referenced: ipv1, Zach, tyler, etc (sorry if I messed anyone)
And the folks that provided the Raspberry Pi for Dummies Kit (CanaKit) and the useful bits and pieces in there.
Let me just say this: I am glad I came here, and I hope others find this helpful.
Looks like a fun place to find help and suggestions.
If you folks want pics, and I can get away with posting them, just ask!
N00b with dirty fingers,
P.S. If someone has more elegant code for this, Please let me know!
Thanks again everyone!