Last active
April 4, 2018 08:36
-
-
Save Pillar1989/0cb057973381747c132730e27cd2c76f to your computer and use it in GitHub Desktop.
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
""" | |
Control pixel ring on ReSpeaker V2 | |
sudo apt install python-mraa libmraa1 | |
pip install pixel-ring | |
""" | |
import time | |
import logging | |
from pixel_ring import pixel_ring | |
import mraa | |
import os | |
en = mraa.Gpio(12) | |
if os.geteuid() != 0 : | |
time.sleep(1) | |
en.dir(mraa.DIR_OUT) | |
en.write(0) | |
leds = pixel_ring.dev | |
num = 0 | |
if __name__ == '__main__': | |
logging.basicConfig(filename='log.txt',format='%(asctime)s - %(message)s',level=logging.INFO) | |
os.popen("ifconfig wlan0 up") | |
os.popen("dhclient wlan0") | |
while True: | |
try: | |
leds.set_pixel(num, 0, 0, 200) | |
leds.show() | |
time.sleep(1) | |
for line in os.popen("ping -l 16 -c 3 -I wlan0 192.168.2.1 "): | |
logging.info(line[:-1]) | |
leds.set_pixel(num, 0, 0, 0) | |
leds.show() | |
time.sleep(2) | |
except KeyboardInterrupt: | |
break | |
pixel_ring.off() | |
time.sleep(1) | |
en.write(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment