Things used in this project
I wanted to control a motor using CHIP. I found out that the CHIP outputs wouldn't drive a power UJ or MOS,
FET transistor directly so I made a two-transistor circuit. I also used a press-momentary switch to control the motor and an LED to show that the motor is on.
I had the transistors already but to buy them (from eBay for example) the power MOSFETs, IRF510 are about $2 for ten and the 2N3904 UJ NPN transistors are 100 for a quid!
The motor can only be switched on and off with this circuit, it cannot be reversed.
#!/usr/bin/python # # Nick Pettefar - 14th July 2016 # import CHIP_IO.GPIO as GPIO from time import sleep # delay=0.01 Motor = "XIO-P2" LED = "XIO-P4" Switch = "XIO-P0" GPIO.setup(Motor, GPIO.OUT) GPIO.setup(LED, GPIO.OUT) GPIO.setup(Switch, GPIO.IN, pull_up_down=GPIO.PUD_UP) # GPIO.output(Motor, GPIO.LOW) GPIO.output(LED, GPIO.LOW) try: while True: while GPIO.input(Switch)==1: sleep(delay) GPIO.output(Motor, GPIO.HIGH) GPIO.output(LED, GPIO.HIGH) sleep(delay) GPIO.output(Motor, GPIO.LOW) GPIO.output(LED, GPIO.LOW) except KeyboardInterrupt: GPIO.output(Motor, GPIO.LOW) GPIO.output(LED, GPIO.LOW)
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!