WebVisitors blinker

I already wrote my first Arduino program. It’s really simple but fun :)

What it does is that every time somebody visits my website, a LED light blinks once in my room, and I get a warm feeling of a visitor ;)

How to do that:

  • Burn this code to your Arduino:
  • Connect a LED light to pin 12 and ground it.
  • Connect your Arduino to your web server through USB.
  • Log in to your web server and type: “sudo chmod 666 /dev/ttyUSB0”.
  • Add this PHP code to your website header:
  • Enjoy! :)

In case this doesn’t work; try to solve your problem or comment this article and I will try to help you.

Arduino Diecimila

9 thoughts on “WebVisitors blinker”

    • You would need to do some work on your web page side. In the user_has_visited_before() function, you would put whatever logic you need to determine the scenario where the blink should occur again.

      With something like this logic
      /dev/ttyUSB0″);

      //blink again if the user has visited before
      if(user_has_visited_before()){
      exec(“echo 1 > /dev/ttyUSB0”);
      }

      ?>

      Reply
  1. Log in to your web server and type: “sudo chmod 666 /dev/ttyUSB0″

    Could you please explain the above or point me in the right direction for some reading on it, i have hosting but not sure where I put this

    Reply
    • You have to own your own server preferably in your home since you have to physically attach the arduino to it. Hosting on a remote server wont work with this solution. However, you could try to write a PHP script to notify your home computer whenever you have a visitor.

      Reply
  2. The same question for me, please help me.
    How can it works on an hosted web server?
    Thank you

    Reply
  3. Hi,
    That’s a neat trick. I’d like to expand it to do more from a website. Let’s say you have buttons on a webpage, and each button sends a different “code” to the Arduino.

    When the webserver (which could be a Raspberry Pi) runs the code “echo 1 > /dev/ttyUSB0”, it’s sending a value of “1” to the Arduino on USB0 right?

    On the Arduino, why do you check if the value is greater than 0 and less than or equal to 9? Why not just look to see if the value is “1”. I don’t understand what possible values other than 1 the Arduino could receive from the webserver…it seems like the loop will always run just once?

    Also, why did you do this? val is an int, and you’re subtracting the value of the “0” character?
    val = val – ‘0’;

    Reply

Leave a Comment