Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackRaspi/status/864555003146625024
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

I want to make a on/off signal with only a push button, exuallyactually its for my WiiMote but I dontdon't think that that makes a difference. I want a led to turn it on ansand off.

I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0  (0 would be OFF). I have seen other posts about this and tried them, but none offof them workswork:(

This is what I tried.

while trueTrue:
  if (GPIO.input(11) == 1):
    if (status == 0):
      GPIO.output(22, 0)
      status = 1

    if (status == 1):
      GPIO.output(22, 1)
      status = 0

And:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(22, GPIO.OUT) # LED
GPIO.setup(11, GPIO.IN) # Button

def toggleLEDcallback(channel):
    if (GPIO.input(22) == True):
        GPIO.output(22, False)
    else:
        GPIO.output(22, True)

while 1True:
    ...
    # do some other stuff
    ...
GPIO.cleanup()

I tried also with 2 transistors but that didntdidn't work either. Any other hardware Solutions?

I hope one offof you would like to help me building my robot!!

Below I paste a photo offof my robot, for in case you where wondering how it looks like;)

Thanks!

I want to make a on/off signal with only a push button, exually its for my WiiMote but I dont think that that makes a difference. I want a led to turn it on ans off.

I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0(0 would be OFF). I have seen other posts about this and tried them, but none off them works:(

This is what I tried.

while true:
  if (GPIO.input(11) == 1):
    if (status == 0):
      GPIO.output(22, 0)
      status = 1

    if (status == 1):
      GPIO.output(22, 1)
      status = 0

And:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(22, GPIO.OUT) # LED
GPIO.setup(11, GPIO.IN) # Button

def toggleLEDcallback(channel):
    if (GPIO.input(22) == True):
        GPIO.output(22, False)
    else:
        GPIO.output(22, True)

while 1:
    ...
    # do some other stuff
    ...
GPIO.cleanup()

I tried also with 2 transistors but that didnt work either. Any other hardware Solutions?

I hope one off you would like to help me building my robot!!

Below I paste a photo off my robot, for in case you where wondering how it looks like;)

Thanks!

I want to make a on/off signal with only a push button, actually its for my WiiMote but I don't think that that makes a difference. I want a led to turn it on and off.

I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0  (0 would be OFF). I have seen other posts about this and tried them, but none of them work:(

This is what I tried.

while True:
  if (GPIO.input(11) == 1):
    if (status == 0):
      GPIO.output(22, 0)
      status = 1

    if (status == 1):
      GPIO.output(22, 1)
      status = 0

And:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(22, GPIO.OUT) # LED
GPIO.setup(11, GPIO.IN) # Button

def toggleLEDcallback(channel):
    if (GPIO.input(22) == True):
        GPIO.output(22, False)
    else:
        GPIO.output(22, True)

while True:
    ...
    # do some other stuff
    ...
GPIO.cleanup()

I tried also with 2 transistors but that didn't work either. Any other hardware Solutions?

I hope one of you would like to help me building my robot!!

Below I paste a photo of my robot, for in case you where wondering how it looks like;)

Thanks!

indented code to display correctly
Source Link
goldilocks
  • 60.1k
  • 17
  • 115
  • 230

I want to make a on/off signal with only a push button, exually its for my WiiMote but I dont think that that makes a difference. I want a led to turn it on ans off.

I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0(0 would be OFF). I have seen other posts about this and tried them, but none off them works:(

This is what I tried.

while true: if (GPIO.input(11) == 1): if (status == 0): GPIO.output(22, 0) status = 1

while true:
  if (GPIO.input(11) == 1):
    if (status == 0):
      GPIO.output(22, 0)
      status = 1

    if (status == 1):
      GPIO.output(22, 1)
      status = 0

And:

mport RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(22, GPIO.OUT) # LED GPIO.setup(11, GPIO.IN) # Button

def toggleLEDcallback(channel): if (GPIO.input(22) == True): GPIO.output(22, False) else: GPIO.output(22, True)

while 1: ... # do some other stuff ... GPIO.cleanup()

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(22, GPIO.OUT) # LED
GPIO.setup(11, GPIO.IN) # Button

def toggleLEDcallback(channel):
    if (GPIO.input(22) == True):
        GPIO.output(22, False)
    else:
        GPIO.output(22, True)

while 1:
    ...
    # do some other stuff
    ...
GPIO.cleanup()

I tried also with 2 transistors but that didnt work either. Any other hardware Solutions?

I hope one off you would like to help me building my robot!!

Below I paste a photo off my robot, for in case you where wondering how it looks like;)

Thanks!

I want to make a on/off signal with only a push button, exually its for my WiiMote but I dont think that that makes a difference. I want a led to turn it on ans off.

I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0(0 would be OFF). I have seen other posts about this and tried them, but none off them works:(

This is what I tried.

while true: if (GPIO.input(11) == 1): if (status == 0): GPIO.output(22, 0) status = 1

if (status == 1):
  GPIO.output(22, 1)
  status = 0

And:

mport RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(22, GPIO.OUT) # LED GPIO.setup(11, GPIO.IN) # Button

def toggleLEDcallback(channel): if (GPIO.input(22) == True): GPIO.output(22, False) else: GPIO.output(22, True)

while 1: ... # do some other stuff ... GPIO.cleanup()

I tried also with 2 transistors but that didnt work either. Any other hardware Solutions?

I hope one off you would like to help me building my robot!!

Below I paste a photo off my robot, for in case you where wondering how it looks like;)

Thanks!

I want to make a on/off signal with only a push button, exually its for my WiiMote but I dont think that that makes a difference. I want a led to turn it on ans off.

I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0(0 would be OFF). I have seen other posts about this and tried them, but none off them works:(

This is what I tried.

while true:
  if (GPIO.input(11) == 1):
    if (status == 0):
      GPIO.output(22, 0)
      status = 1

    if (status == 1):
      GPIO.output(22, 1)
      status = 0

And:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(22, GPIO.OUT) # LED
GPIO.setup(11, GPIO.IN) # Button

def toggleLEDcallback(channel):
    if (GPIO.input(22) == True):
        GPIO.output(22, False)
    else:
        GPIO.output(22, True)

while 1:
    ...
    # do some other stuff
    ...
GPIO.cleanup()

I tried also with 2 transistors but that didnt work either. Any other hardware Solutions?

I hope one off you would like to help me building my robot!!

Below I paste a photo off my robot, for in case you where wondering how it looks like;)

Thanks!

added 1017 characters in body; deleted 710 characters in body
Source Link

I want to make a on/off signal with only a push button, exually its for my WiiMote but I dont think that that makes a difference. I want a led to turn it on ans off.

I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0(0 would be OFF). I have seen other posts about this and tried them, but none off them works:(

This is what I tried. I dont know the exact code but it begins with this

while true: if (GPIO.input(11) == 1): if (status == 0): GPIO.output(22, 0) status = 1

State = 0

Ifif (input) =1:
    If Statestatus == 1): 
        State = 0 
    Elif state == 0:GPIO.output(22, 1)
        Statestatus = 10

And:

mport RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(22, GPIO.OUT) # LED GPIO.setup(11, GPIO.IN) # Button

def toggleLEDcallback(channel): if (GPIO.input(22) == True): GPIO.output(22, False) else: GPIO.output(22, True)

while 1: ... # do some other stuff ... GPIO.cleanup()

I tried also with 2 transistors but that didnt work either. Any other hardware Solutions?

I hope one off you would like to help me building my robot!!

Below I paste a photo off my robot, for in case you where wondering how it looks like;)

Thanks!

I want to make a on/off signal with only a push button, exually its for my WiiMote but I dont think that that makes a difference. I want a led to turn it on ans off.

I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0(0 would be OFF). I have seen other posts about this and tried them, but none off them works:(

This is what I tried. I dont know the exact code but it begins with this.

State = 0

If (input) =1:
    If State == 1: 
        State = 0 
    Elif state == 0: 
        State = 1

I tried also with 2 transistors but that didnt work either. Any other hardware Solutions?

I hope one off you would like to help me building my robot!!

Below I paste a photo off my robot, for in case you where wondering how it looks like;)

Thanks!

I want to make a on/off signal with only a push button, exually its for my WiiMote but I dont think that that makes a difference. I want a led to turn it on ans off.

I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0(0 would be OFF). I have seen other posts about this and tried them, but none off them works:(

This is what I tried.

while true: if (GPIO.input(11) == 1): if (status == 0): GPIO.output(22, 0) status = 1

if (status == 1):
  GPIO.output(22, 1)
  status = 0

And:

mport RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(22, GPIO.OUT) # LED GPIO.setup(11, GPIO.IN) # Button

def toggleLEDcallback(channel): if (GPIO.input(22) == True): GPIO.output(22, False) else: GPIO.output(22, True)

while 1: ... # do some other stuff ... GPIO.cleanup()

I tried also with 2 transistors but that didnt work either. Any other hardware Solutions?

I hope one off you would like to help me building my robot!!

Below I paste a photo off my robot, for in case you where wondering how it looks like;)

Thanks!

added 54 characters in body
Source Link
Milliways
  • 61.5k
  • 32
  • 108
  • 212
Loading
added 37 characters in body
Source Link
Loading
added 273 characters in body
Source Link
Loading
Source Link
Loading