Connect a Vandal Switch with Raspberry-Pi and register an Input/Output with a click

52 views Asked by At

I want to connect a Vandal Switch(CPS) with an Raspberry Pi, there i want to register via an Phython program when the Button is Pressed and change the Led light from blue to Red.

How i connected the Cables to the Raspberry Pi:

  • Brown cable -> 5V Power
  • Black cable -> Ground
  • Black cable -> Ground
  • white cable 1 -> GPIO5
  • White cable 2 -> GPIO6
  • Green cable (green LED) -> GPIO2
  • Blue cable (blue LED) -> GPIO3
  • Red cable (red LED) -> GPIO4

I´ve tried this in phyton on the Raspberry Pi:

from gpiozero import Button, LED
from signal import pause

led = LED(3)
button = Button(5)

button.when_pressed = led.on
button.when_pressed = led.off
pause()

Error: No module named "gpiozero"

I've installed the module via console command:

sudo apt update
sudo apt install phyton-gpiozero

(it says that it is already on the newest version)

0

There are 0 answers