Odd layout Basic circuitry, ground, resistors, input/ pullup

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
threewheeler80
 
Posts: 12
Joined: Wed Feb 10, 2021 2:10 am

Odd layout Basic circuitry, ground, resistors, input/ pullup

Post by threewheeler80 »

This project started as a stop motion, and is gradually turning into more.

Here is the script, which needs critiqued...

Code: Select all

#importing the necessary modules
from datetime import datetime
from gpiozero import Button, LED
from picamera import PiCamera
from time import sleep
from signal import pause

imagebutton = Button(23)
red = LED(17)
previewbutton = Button(24)
white = LED(27)
videobutton = Button(25)
blue = LED(22)
camera = PiCamera()
running = True
camera.resolution = (1024, 768)#use this to set the resolution
white.source = previewbutton.values
red.source = imagebutton.values
blue.source = videobutton.values
previewbutton.when_pressed = camera.start_preview
previewbutton.when_released = camera.stop_preview
timestamp = datetime.now()

def picture():
    camera.capture('pic'+str(timestamp)+'.jpg')
sleep(2) #give the camera two seconds
imagebutton.when_pressed = picture #execute the picture function

def video():
    camera.start_recording('vid'+str(timestamp)+'.h264')
    camera.wait_recording(15)
    camera.stop_recording
sleep(2)
videobutton.when_pressed = video #execute the video function

try:
    while running:
        print('Active') #displaying 'Active' to the shell
        sleep(1)

#we detect Ctrl+C then quit the program
except KeyboardInterrupt:
    camera.stop_preview()
    running = False

pause()#keep the script alive
There is an mp4 and fritzing png's at https://github.com/threewheeler80/Stop_Motion

Some questions:
1. Should there have been resistors between the GPIO pins and components? Specifically, a pull down resistor for the arcade buttons?
The code recognizes that the button is pushed when the pin goes high. This means the button will be pulled low and only go high when the button is pressed.

2. Should I have resistors on the negative(cathode) side of the led sequins?

3. The power switch - When the RPI zero is off the led still glows?

As always thank you very much for advice, tips and any help provided.
Sincerely,
Mr. Beginner 1.0 :)
Attachments
permaprotobonnetjumpers.jpeg
permaprotobonnetjumpers.jpeg (43.02 KiB) Viewed 143 times
permaprotobonnetconnectors.jpeg
permaprotobonnetconnectors.jpeg (40.56 KiB) Viewed 143 times
arcadebuttonsenclosure.jpeg
arcadebuttonsenclosure.jpeg (35.8 KiB) Viewed 143 times

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: Odd layout Basic circuitry, ground, resistors, input/ pu

Post by dastels »

1. Yes, the button inputs should have pulldowns on them unless you can set pulldowns internally.

2. No. the LED sequins have an onboard resistor. You don't need an additional one. Just connect 3-6v to them.

3. Can you provide more information?

Dave

User avatar
threewheeler80
 
Posts: 12
Joined: Wed Feb 10, 2021 2:10 am

Re: Odd layout Basic circuitry, ground, resistors, input/ pu

Post by threewheeler80 »

Hello Dave,
Thank you for replying.
1. I am considering enabling a pull-down resistor in the code. Example with the image button:
imagebutton = Button(23, pull-up=False)

3. I have added a shutdown switch for the pi zero using:

Code: Select all

#!/usr/bin/env python3
from gpiozero import Button
import os
Button(21).wait_for_press()
os.system("sudo poweroff")
I noticed when everything is connected but the Pi zero is not on, the led is glowing for the power switch. Is the 3.3v from the Pi always supplying the power to cause this?

I have an mp4 on the github referenced above showing the issue with pressing the preview button and the image red sequin would illuminate temporarily. This may be caused from the pins status floating. Fixing the code may eliminate this issue.

Thank you again for helping.
Three Wheeler

User avatar
threewheeler80
 
Posts: 12
Joined: Wed Feb 10, 2021 2:10 am

Re: Odd layout Basic circuitry, ground, resistors, input/ pu

Post by threewheeler80 »

Update: Made some things better :)!!!

My Python skills are not good, yet. Tried changing the script with no success. Decided to keep the python script mostly the same for now and install resistors on the pin inputs for the buttons. Plugged everything in, and noticed the red led sequin was dim. Long story short, clean the flux off the pcb's.

Still debating on the power switch led, this may be solved with some code fix.
Oh, and the video capture is longer than 15 seconds, but this may be a code thing too?
Attachments
Cleaned with a toothbrush, isopropyl alcohol and compressed air
Cleaned with a toothbrush, isopropyl alcohol and compressed air
unflux_a_fied.jpeg (44.31 KiB) Viewed 55 times
the residual flux
the residual flux
flux_a_fied.jpeg (39.13 KiB) Viewed 55 times
resistors on the pins, utilizing the default pin state, of HIGH or On
resistors on the pins, utilizing the default pin state, of HIGH or On
installed_resistors.jpeg (43.14 KiB) Viewed 55 times

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”