Python Forum
raspberry pi in a python script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
raspberry pi in a python script
#1
Quote:Hey everyone
so I have this simple function for my raspberry pi
and I made a python file it does work

from gpiozero import LED
from gpiozero.pins.pigpio import PiGPIOFactory

# this IEP address is assigned to raspberry pi
factory = PiGPIOFactory(host='pi's IP address')
Switch_1 = LED(18, pin_factory=factory)
Switch_2 = LED(23, pin_factory=factory)
Switch_3 = LED(24, pin_factory=factory)


Switch_1.on()
Switch_2.on()
Switch_3.on()
But the problem I'm running into
I tried to merge it into another python file
and put it under a function which I called
def raspberry_pi():
but for whatever reason it doesn't work I'm having a hard time understanding why

Under that function I can call the file and it will work
I just can't put everything under the function I don't understand what's going on

Has anyone ran into this problem
Reply


Messages In This Thread
raspberry pi in a python script - by Raysz - Jun-05-2024, 12:44 PM
RE: raspberry pi in a python script - by deanhystad - Jun-05-2024, 05:20 PM
RE: raspberry pi in a python script - by jefsummers - Jun-05-2024, 10:02 PM
RE: raspberry pi in a python script - by Raysz - Jun-06-2024, 03:09 PM
RE: raspberry pi in a python script - by deanhystad - Jun-06-2024, 09:32 PM
RE: raspberry pi in a python script - by jefsummers - Jun-08-2024, 07:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Building specific Python version on Raspberry PI 5 (Raspbian) andrewk 2 844 Feb-03-2025, 11:41 AM
Last Post: iterate
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 8,444 Jun-29-2023, 11:57 AM
Last Post: gologica
  Video recording with Raspberry Pi - What´s wrong with my python code? Montezuma1502 3 2,542 Feb-24-2023, 06:14 PM
Last Post: deanhystad
  Coding for Python and Raspberry pi beast 3 64,153 Sep-21-2021, 09:56 PM
Last Post: beast
  python 3 raspberry pi 4 dual control motor programming problem yome 0 2,702 Mar-21-2021, 05:17 PM
Last Post: yome
  Embedded python fails to compile on Raspberry Pi tryfon 2 4,804 Dec-22-2020, 02:06 PM
Last Post: tryfon
  Uploading files to NAS from Raspberry PI using python zazas321 0 3,359 Sep-07-2020, 09:02 AM
Last Post: zazas321
  Port my python program to Raspberry pi seamlessly Hassibayub 1 2,688 Jun-29-2020, 12:58 PM
Last Post: snippsat
  How to kill a bash script running as root from a python script? jc_lafleur 4 8,294 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 3,065 May-28-2020, 05:27 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020