Posts

Showing posts with the label raspberry-pi

Python - How can I run two dependant funtions at the same time?

Python - How can I run two dependant funtions at the same time? I have two funtions, one runs increasing by one a number, and the other needs to capture the number that is running the first function every 5 seconds, so that when I capture the first number is 0, the sencond one is 10, the next one is 15, and so on... this is simulating the first function as a sensor. My code is as follows: import time import threading from threading import Thread def numero(i=0): while True: i = i + 1 time.sleep(1) #print i def capturar(): while True: posicion = numero() time.sleep(5) print posicion if __name__ == '__main__': Thread(target = capturar()).start() Thread(target = numero()).start() When I run this code, it keeps in the first function, how can I get this run correctly and obtain the capture of the series of numbers every 5 seconds? First thing first, numero never returns or yields anything, so you'll always get None fr...

Convert GPIO to 5V output

Convert GPIO to 5V output i wanted to ask An unusual question... I guess? Is there any way to use a normal GPIO pin as a 5V output pin? I am using a screen that prevent access to all power outputs, so i have only the normal GPIO pins and ground pins (not mentioning about the id_sc and id_sd pins) The tag wiki snippet for the raspberry-pi tag says "PROGRAMMING QUESTIONS ONLY. Questions about using it should be asked on raspberrypi.stackexchange.com – Robin Green Jul 1 at 21:26 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.