Did some testing and the LED works!
The Arduino script:
int blinks = 0; // amount of blinks
void setup() {
int ledPin = 13;
pinMode(ledPin, OUTPUT); // Set LED pin as an output pin
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
blinks += Serial.read();
Serial.println(blinks);
if (blinks > 0) {
int ledPin = 13;
digitalWrite(ledPin, HIGH); //sets LED on
delay(3000); //waits for 3 seconds
digitalWrite(ledPin, LOW); //sets LED off
blinks--;
}
}
}
And here the Python script:
fetch counter
import time
import urllib
import serial
usb serial connection to arduino
ser = serial.Serial(
'/dev/cu.usbserial-A600ai7x', 9600)
myUrl = 'http://mywebsite.nl/hitcounter2.txt'
last_counter = urllib.urlopen(myUrl).read()
while (True):
counter = urllib.urlopen(myUrl).read()
delta = int(counter) - int(last_counter)
print "counter: %s, delta: %s" % (counter, delta)
ser.write(chr(ord(chr(delta))))
last_counter = counter
time.sleep(1)
;D