You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Elis Axelsson d3edd355dc
Add crazy code and docs
6 years ago
code Add crazy code and docs 6 years ago
.gitignore Ignore /.env/ dir 6 years ago
Makefile Add wrapper to connect 6 years ago
README.org Add crazy code and docs 6 years ago
default.nix Add deps 6 years ago
requirements.txt Added requirements.txt 6 years ago

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 main, time

while True:
    print(main.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 main, time

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

Relay

Pins

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

Set up relays

import main

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

# Move table up
main.toggleRaiseUp()

# Move table down
main.toggleLowerDown()

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