Permalink
Please sign in to comment.
Showing
with
64 additions
and 0 deletions.
- +42 −0 L293D_pump_code.py
- +22 −0 ps pump equipment list and notes.txt
| @@ -0,0 +1,42 @@ | ||
| +# this uses the Adafruit PWM kernel library in their Occidentalis distro | ||
| +import RPi.GPIO as io | ||
| +io.setmode(io.BCM) | ||
| + | ||
| +in1_pin = 4 | ||
| +in2_pin = 17 | ||
| + | ||
| +io.setup(in1_pin, io.OUT) | ||
| +io.setup(in2_pin, io.OUT) | ||
| + | ||
| +def set(property, value): | ||
| + try: | ||
| + f = open("/sys/class/rpi-pwm/pwm0/" + property, 'w') | ||
| + f.write(value) | ||
| + f.close() | ||
| + except: | ||
| + print("Error writing to: " + property + " value: " + value) | ||
| + | ||
| +set("delayed", "0") | ||
| +set("mode", "pwm") | ||
| +set("frequency", "500") | ||
| +set("active", "1") | ||
| + | ||
| +def clockwise(): | ||
| + io.output(in1_pin, True) | ||
| + io.output(in2_pin, False) | ||
| + | ||
| +def counter_clockwise(): | ||
| + io.output(in1_pin, False) | ||
| + io.output(in2_pin, True) | ||
| + | ||
| +clockwise() | ||
| + | ||
| +while True: | ||
| + cmd = raw_input("Command, f/r 0..9, E.g. f5 :") | ||
| + direction = cmd[0] | ||
| + if direction == "f": | ||
| + clockwise() | ||
| + else: | ||
| + counter_clockwise() | ||
| + speed = int(cmd[1]) * 11 | ||
| + set("duty", str(speed)) |
0 comments on commit
4ed392f