Jump to content

Python Help

TheCoder2019

Hi, I need help figuring out why Switch 3 is being printed no matter what. It does this properly for switch 1 and 2, but continues to print switch 3 as on, when it is off. Here is the picture of my code, sorry it’s not really legible...

 

EDIT: These are generic brand light switches from Walmart for $0.67 a piece, couldn’t resist. They work well too.

 

B84FDF4F-59EF-426A-AEEE-3D9927083C5D.jpeg

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

use different variable name fo input_value like input_value1 , input_value2,input_value3

and after the first if statement use elif

like this

input_value1
if input_value1 == false :
whatever
input_value2
elif input_value2 == false :
whatever

input_value3
elif input_value3 == false :
whatever

 

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, mahyar said:

use different variable name fo input_value like input_value1 , input_value2,input_value3

and after the first if statement use elif

like this

 

*snip*

Let me try that

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

Wait... now I am using the RPi.GPIO library, if I use those other variables, it’s now undefined so now what

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, TheCoder2019 said:

Wait... now I am using the RPi.GPIO library, if I use those other variables, it’s now undefined so now what

just use the output of library directly

dont add that input value thingy

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

How do I do that? I’m still kind of learning Python

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, TheCoder2019 said:

How do I do that? I’m still kind of learning Python

quote me

remove input value and use GPIO.input(switchx)

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

Like this?

 

GPIO.input(switchX, HIGH)

 

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, TheCoder2019 said:

Like this?

 


GPIO.input(switchX, HIGH)

 

no 

if gpio.input(switchx) == false :

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, mahyar said:

no 

if gpio.input(switchx) == false :

I’m gonna try it... I’ll try to be back in 5 mins?

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, TheCoder2019 said:

I’m gonna try it... I’ll try to be back in 5 mins?

btw use elif as i showed above

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, mahyar said:

btw use elif as i showed above

OK

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

So I did elif statements and the terminal is still getting spammed by saying switch 3 is on

 

Is this code correct?

04B0AAD9-CE35-4F7C-ABD7-50E6F4012FDF.jpeg

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, TheCoder2019 said:

So I did elif statements and the terminal is still getting spammed by saying switch 3 is on

 

Is this code correct?

04B0AAD9-CE35-4F7C-ABD7-50E6F4012FDF.jpeg

well idk much more 

i usually code this sort of stuff c/c++ those were only things i could see wrong with your code

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

I DID notice when I switched Switch 3 to True, it would stop, but the light switch is now inverted which will annoy me. Anything there?

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, TheCoder2019 said:

I DID notice when I switched Switch 3 to True, it would stop, but the light switch is now inverted which will annoy me. Anything there?

wait are you sure that led you are using is good? did you use pullup resistors? how are switches wired?

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

Let me draw it. This may take a while

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

@mahyar K. Here it is. I am not using pullup resistors because they worked fine without, with no bouncing

 

 

burner.png

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, TheCoder2019 said:

@mahyar K. Here it is. I am not using pullup resistors because they worked fine without, with no bouncing

 

 

burner.png

rpi has internal pullup resistors enablee them

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

How? sudo raspi-config? Or another bash command?

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, TheCoder2019 said:

How? sudo raspi-config? Or another bash command?

none you have to do it in python

google it

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

Most of what I find is in Java. Do you mind sourcing the code for me? Sorry for being a pain, I’ll follow for your troubles with me

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, TheCoder2019 said:

Most of what I find is in Java. Do you mind sourcing the code for me? Sorry for being a pain, I’ll follow for your troubles with me

ok

if it was useful give it a like :) btw if your into linux pay a visit here

 

Link to comment
Share on other sites

Link to post
Share on other sites

That’s literally what I’ve just read 5 mins ago. It works well, no repeated echo. I would call this thread a success. Thank you for sticking around the 1 hour and 30 some minutes you did

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×