Last active
December 18, 2015 11:39
-
-
Save CamDavidsonPilon/5776946 to your computer and use it in GitHub Desktop.
reflexive art project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android | |
from time import sleep | |
from requests import post | |
droid = android.Android() | |
SERVER = "http://artech.herokuapp.com" | |
ID = 0 | |
""" | |
Starts recording sensor data to be available for polling. | |
sensorNumber (Integer) 1 = All, 2 = Accelerometer, 3 = Magnetometer and 4 = Light | |
delayTime (Integer) Minimum time between readings in milliseconds | |
""" | |
droid.startSensingTimed(1,5) | |
payload = {"x":0, "y":0, "z":0, #acceleration | |
"light":0, #light | |
"azimuth":0, "roll":0, "pitch":0, #orientation | |
"ID":ID, | |
} | |
readSensors = droid.readSensors | |
sleep(2) | |
while(1): | |
result = readSensors().result | |
payload["z"] = (result['zforce']) | |
payload["x"] = (result['xforce']) | |
payload["y"] = (result['yforce']) | |
payload["light"] = (result['light'] ) | |
payload["pitch"] = ( result["pitch"] ) | |
payload["azimuth"] = ( result["azimuth"] ) | |
payload["roll"] = ( result["roll"] ) | |
post(SERVER, data = payload ) | |
sleep(0.02) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment