Greet me!

Good evening, so, well, I'll just present my Arduino project. I connected the Arduino to a 4x20 SerLCD2.5, read data out of the Serial Stream and saved that into a variable. The var then got displayed on the LCD. After I had a lot of fun displaying stuff on my LCD, I thought "Why shouldn't everyone be able to do that?". So I wrote a PHP Script and a small Program in C#. Now people can access my website, write there some greeting down, then my C# program on my local computer reads the greeting over a php script out of the MySQL-Database and sends it via the Serial Port to the Arduino, which displays the greeting. After a Test-Run, I saw that some Idiots thought it would be funny writing down racist/nazi stuff, so I had to implement a wordfilter, a logging-System and a ban system. To prevent flooding there can be only 1 greeting all 5 minutes. If anyone wants the link to the website, PM me or something, I don't like when it gets spammed. :>

Schematic (german, but I think it isn't too complex):

cool, would you share your code?

(auch in Deutsch ;))

I’ll just paste the very messy coded C#-Program and the Arduino Code. But I think the PHP-Script is too shitty to share :slight_smile:


using System;

using System.IO;

using System.IO.Ports;

using System.Net;

using System.Text;

public class greetme


      static SerialPort _serialPort;

      public static void Main()


            StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;

            while (true)


                  _serialPort = new SerialPort();

                  _serialPort.PortName = "COM5";

                  _serialPort.BaudRate = 9600;

                  _serialPort.Parity = Parity.None;

                  _serialPort.DataBits = 8;

                  _serialPort.StopBits = StopBits.One;

                  _serialPort.Handshake = Handshake.None;


                  StringBuilder sb  = new StringBuilder();

                  byte[] buf = new byte[128];

                  HttpWebRequest  request  = (HttpWebRequest)


                  HttpWebResponse response = (HttpWebResponse)


                  Stream resStream = response.GetResponseStream();

                  string tempString = null;

                  int    count      = 0;



                        // fill the buffer with data

                        count = resStream.Read(buf, 0, buf.Length);

                        // make sure we read some data

                        if (count != 0)


                              // translate from bytes to ASCII text

                              tempString = Encoding.ASCII.GetString(buf, 0, count);

                              // continue building the string




                  while (count > 0); // any more data to read?





                  if(stringComparer.Equals("", sb.ToString()) == false)











Most of the code is copy-pasted from somewhere, I couldn’t even program C# when I started with the project.


char message[60] = "Default String";
int count = 0;
int msglen = 13;
int i = 0;
void setup() {

void loop() {
  if(count != 0) {
    msglen = count - 1;
    count = 0;
  while(Serial.available() > 0) {
    message[count] = char(;
  Serial.print(0xFE, BYTE);
  for(int i = 0; i <= msglen; i++) {

I hope you didn’t puke because of my codes :>

thanks for sharing :)

the php code would be also interesting, as it makes in my case the part where i have no idea how to do such a thing :-[

Okay, I’ll just make a short explanation:
The PHP-Script index.php first removes all registered IPs which are older than 5 minutes (function time()) and not banned, then it gets the post data for the greeting-Parameter. If it’s not “” (nothing), it checks for bad words (MySQL-Query, stristr-PHP-Function) After that, it checks that the IP of the user hasen’t been registered lately. If everything is ok, it sends 2 MySQL-Querys: One to add the IP (and the time of adding) of the greeter, and one to add the greeting.
Last but not least in the greeting-routine, it adds a new entry in the log-table with IP, time and message.
At the end of the Script, it will just present a HTML-Form for the greeting.
In a second script, it first checks if the password in the get-parameter is the right one, then it gives out the first greeting (MySQL-Query just needs a “LIMIT 1” at the end) with echo and deletes it. That’s it. :slight_smile:

A little overview of the databasetables:

Log greeting greeters banned_words
ip id id word
msg msg ip warn
time(Timestamp) timestamp(PHP-Timestamp this time

The warn-Field at “banned_words” is 1 or 2. The bannedword-check in the script adds the warn-values of each bad word in the greeting. If the result is 2 or higher, the ip will get banned. So if someone writes something about his ass, he won’t be banned instantly. :slight_smile:

I hope you can understand it, I know, I could have done it better =D
Since you are german: has good PHP and MySQL-Tutorials in german. Helped me alot!

Can't you control arduino directly with PHP? I think it's possible with fopen("COM*") etc.

That would mean that I’d have to run a webserver on my local computer. I just have some webspace. :slight_smile: