Things used in this project

Hardware components:
Chip%20v1
C.H.I.P.
×1
DC motor (generic)
×1
Omron b3f 1000 image 75px
SparkFun Pushbutton switch 12mm
×1
09590 01
LED (generic)
×1
Fairchild semiconductor fqu13n06ltu image 75px
Power MOSFET N-Channel
I used an IRF510
×1
Fairchild semiconductor pn2222abu. image
General Purpose Transistor NPN
I used an 2N3904
×1
Mfr 25fbf52 4k75 sml
Resistor 4.75k ohm
×2
12002 04
Breadboard (generic)
×1
Male/Male Jumper Wires
Some wires...
×10

Schematics

The Circuit Diagram
Wire it up carefully.
Circuit diagram.jpg

Code

MotorOnSw.pyPython
Press the button to switch the motor and LED on.

You need to install the AdaFruit C.H.I.P. GPIO library first of all. See here for instructions, usage guides and tips and other stuff: https://bbs.nextthing.co/t/adafruit-gpio-library-for-chip/2696
#!/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)

Credits

Nick head
Nick Pettefar
2 projects • 1 follower
Unix biker Radio Ham bad Ukulele player.
Contact

Comments

Add projectSign up / Login