Page 1 of 1

Wiring buttons and LED - trigger script

Posted: Thu Feb 16, 2017 10:25 am
by ovarland
Hi!

I am attempting to make a Raspberry pi 3 into to a Tiny Backup box that will backup my sd-cards from my camera automatically. I have been following this tutorial: http://www.linux-magazine.com/Issues/20 ... sed-Backup and have gotten all the scripts to work.

But I can't get the buttons or LED:s to work. In his wiring diagram he has wired the buttons and LED to the SDA pin and TXD pin. When I google most seem to wire to 3,3v pin and a GND pin. Is there any specific reason to wire to SDA/TXD pin?
Image

I also found that you can enable SPI and IC2 in raspi-config? Is this something I need to do?

Any tips on how I would wire the buttons and LED otherwise?

This is the script that utilizes the buttons and LED.

Code: Select all

01 #!/usr/bin/env python
02 from time import sleep
03 import os
04 import RPi.GPIO as GPIO
05 GPIO.setmode(GPIO.BCM)
06 GPIO.setwarnings(False)
07 GPIO.setup(17, GPIO.IN)
08 GPIO.setup(23, GPIO.IN)
09 GPIO.setup(25, GPIO.OUT)
10 GPIO.output(25, True)
11 while True:
12         if (GPIO.input(17) == False ):
13                 os.system('./get-all-files.sh')
14                 GPIO.output(25, False)
15         if (GPIO.input(23) == False):
16                 os.system('sudo halt')
17         sleep(0.1);

Re: Wiring buttons and LED - trigger script

Posted: Thu Feb 16, 2017 10:50 am
by texy
Hi and welcome to the forum.
Looks like that wiring going to pin 3 (SDA) should be going to pin 1 (3V3).....

Texy

Re: Wiring buttons and LED - trigger script

Posted: Thu Feb 16, 2017 10:57 am
by ovarland
texy wrote:Hi and welcome to the forum.
Looks like that wiring going to pin 3 (SDA) should be going to pin 1 (3V3).....

Texy
Could it be that easy?! Will try as soon as I get home from work!! Cheers!

Re: Wiring buttons and LED - trigger script

Posted: Thu Feb 16, 2017 12:21 pm
by texy
Alternatively you could use pin 3 to drive the pull-up resistors - if I am seeing it right, the circuit is using 2 x 10K resistors, so it should be OK to do that.
Add an additional line in the code.
After this line :

Code: Select all

GPIO.setup(25, GPIO.OUT)
add this new line :

Code: Select all

GPIO.setup(2, GPIO.OUT)

Texy

Re: Wiring buttons and LED - trigger script

Posted: Thu Feb 16, 2017 12:34 pm
by ovarland
texy wrote:Alternatively you could use pin 3 to drive the pull-up resistors - if I am seeing it right, the circuit is using 2 x 10K resistors, so it should be OK to do that.
Add an additional line in the code.
After this line :

Code: Select all

GPIO.setup(25, GPIO.OUT)
add this new line :

Code: Select all

GPIO.setup(2, GPIO.OUT)
Texy
Ah, okay! Will try this! Yes, that's right! 2 x 10k resistors wired before the buttons!

What about the black wire to the TXD pin? Why that one and not a GND pin?

Thanks again.

Re: Wiring buttons and LED - trigger script

Posted: Thu Feb 16, 2017 12:43 pm
by texy
Aaah - sorry I didn't spot that. You are correct, should be connected to pin 6. Looks like when he drew it up, he shift both those wires by 1 place :roll:

Texy

Re: Wiring buttons and LED - trigger script

Posted: Thu Feb 16, 2017 12:43 pm
by ovarland
If I look closely on this picture, it looks like he has wired it to 3V3 pin and GND? Bit hard to tell tho...

Image

Re: Wiring buttons and LED - trigger script

Posted: Thu Feb 16, 2017 12:44 pm
by ovarland
texy wrote:Aaah - sorry I didn't spot that. You are correct, should be connected to pin 6. Looks like when he drew it up, he shift both those wires by 1 place :roll:

Texy
Ah! Awesome! Hehe, yes. Not good when making a tutorial! :D

Thanks again!

Re: Wiring buttons and LED - trigger script

Posted: Thu Feb 16, 2017 8:13 pm
by ovarland
Ha! Works like a charm now!! It was as simple as that, 3V3 and GND.... :D

Thanks for the help!

Now I just need to 3d print a case for my little backup box. :)