abishur wrote:Thanks for the vid Gordan, I may have had a touch of insomnia last night caused by working this out continually in my mind until I got up and build the circuit with my bredboard too
About your program (finally an area I'm good in!

), I'm guessing you've changed the GPIO interface provided and assigned the names red and green to two of the pins. Also, I don't need to use 2 GPIO, right? You were just doing that for my visual benefit.
The program is a bash script - not something I'd recommend for "production" use, but something that can be used to quickly prototype "stuff". So red=0 and green=1 sets the variables red and green to 0 and 1 respectively. And this is when confusion sets in - I wrote my wiringPi library and the gpio program to have a simplified view of the pins to make it familiar to people coming to the Pi from Arduino land, so in wiringPi, pin 0 refers to BCM_GPIO 17 and pin 1 to BCM_GPIO 18, so the input 'red' is GPIO 17 and the output green is GPIO 18.
The gpio program is part of wiringPi - it allows you to control the GPIO pins from the command-line - again, it's not really good for production, but makes it easy to test things out. If you want to see a bigger example, then look at the TuxX (Tux Crossing) program I wrote last week:
http://project-downloads.drogon.net/fil ... es/tuxx.sh
The main article for that is:
https://projects.drogon.net/raspberry-p ... -crossing/
And yes, I put the Green LED there for a visual demo - it was easier to put the LED there than to move that RPi in-front of a screen where I'd just be printing "open" or "closed"
I did change my wiringPi recently to recognise "proper" GPIO numbering too, so if you replaced every call to 'gpio' with 'gpio -g' and changed the assignments to red=17 ; green=18 then it would work just the same.
abishur wrote:A major thanks to
*EVERYONE* whose helped me out on this thread. I'm a little disappoint *none* of my original circuit idea made it in the end, but I'm glad that at least it was due to being overcomplicated rather than flat out wrong!

It is encouraging that I'm slowly but surly getting a handle on this stuff.
Thanks again

One thing I've learned over the years is to not be afraid of throwing away code for something better and I've done it a lot, however I am a bit of an efficiency nut

So when I see things that aren't strictly neccessary I tent to not use them - so e.g. in my circuit, if I were to accidentally set GPIO 17 (signal from the red LED/switch) to an output and write 1 to it, and you pushed the button then you're short-circuiting that pin to ground which may burn out the pin driver, and possibly something else on the SoC... But I acknowledge this and take the risk, as the designers of the Pi did when the wired up the SD card present pin. I (or you!) could put in a 100 ohm series resistor with the signal from the Red LED to the GPIO which would more or less eliminate any real issues while still maintaining working conditions ... but apply that to the Pi and the SD present sensor input - if that resistor and the additional manufacturing costs amount to an extra 1p per board, then when they make 1,000,000 boards, they've cost £10,000 more ... And in the world of tiny tiny margins, that's a lot!
So... A light and a switch doesn't need a computer, but if you arrange it so that adding a computer in to sense the switch is easy, then it's also becomes fun!
Your homework is making the Pi drive a motor to automatically close the garage doors
-Gordon