#!/usr/bin/python

import time
import RPi.GPIO as GPIO

ledPin = 21
GPIO.setmode(GPIO.BCM)
GPIO.setup(ledPin, GPIO.OUT)
GPIO.output(ledPin, GPIO.LOW)

while True:
    try:
	with open('/var/www/testmacro.txt', 'r') as motstat:
		data=motstat.read().replace('\n', '')
	
	if data == "1":
		GPIO.output(ledPin, GPIO.HIGH)
		time.sleep(30)
	else:
		GPIO.output(ledPin, GPIO.LOW)
		time.sleep(2)
    except:
	pass

