Go to file
Elis Axelsson 9c3482d77a Change movement to correct pin 2017-08-21 18:07:19 +02:00
code Change movement to correct pin 2017-08-21 18:07:19 +02:00
.gitignore Ignore /.env/ dir 2017-07-24 17:45:46 +02:00
Makefile Build class 2017-08-21 18:06:29 +02:00
README.org No need to import main 2017-08-17 23:12:52 +02:00
default.nix Add deps 2017-07-24 17:19:09 +02:00
requirements.txt Added requirements.txt 2017-07-24 17:35:20 +02:00

README.org

Setup

virtualenv --no-site-packages --distribute .env
source .env/bin/activate
pip install -r requirements.txt

Connect to serial port

picocom /dev/ttyUSB0 -b115200

Copying file

ampy --port /dev/ttyUSB0 put hcsr04.py

How to connect things

Distance measuring

HCSR04 Pins

Pin on component Pin on card
Trig D2
Echo D3
Vcc 5V
GND GND

Set up distance measuring

import time

while True:
    print(getDistance())
    time.sleep(1)

Movement sensor

Sensor pins

Pin on component Pin on card
5V 5V
GND GND
OUT D4

Set up movement sensor

import time

while True:
    print(getMovement())
    time.sleep(0.5)

Relay

Pins

Pin on component Pin on card
Vcc 5V
Gnd GND
In1 D5
In2 D6

Set up relays

# Use this to reset the state of the relay
resetRelay()

# Move table up
toggleRaiseUp()

# Move table down
toggleLowerDown()

# To go up and down and measure distance and stuff at the same time
goCrazy()