I have a C# Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Collections;
using System.IO.Ports;
namespace CaKey
{
class Program
{
static SerialPort _serialPort;
static void Main(string[] args)
{
_serialPort = new SerialPort();
_serialPort.PortName = "COM7";//Set your board COM
_serialPort.BaudRate = 9600;
_serialPort.Open();
string wort;
int index;
int indexBuchstabe;
int indexEingabe;
int score;
int highscore=0;
bool ende;
string eingabe;
Random random;
StreamReader objReader = new StreamReader(@"E:\Schule\LBK\Projektwoche\german.txt");
string stringLinie = "";
ArrayList Wort = new ArrayList();
while (stringLinie != null)
{
stringLinie = objReader.ReadLine();
if (stringLinie != null)
Wort.Add(stringLinie);
}
objReader.Close();
do
{
Console.Clear();
score = 0;
ende = false;
indexBuchstabe = 0;
index = 0;
ConsoleKeyInfo info;
indexEingabe = 0;
do
{
do
{
random = new Random();
wort = Convert.ToString(Wort[random.Next(11)]);
char[] buchstabe = wort.ToCharArray();
index = 0;
indexBuchstabe = 0;
indexEingabe = 0;
eingabe = "";
do
{
Console.Clear();
Console.Write("Bitte schreiben Sie das Wort " + "\"" + wort + "\":\t" + eingabe);
info = Console.ReadKey(true);
if (info.KeyChar == buchstabe[indexBuchstabe])
{
index++;
indexBuchstabe++;
}
else
{
index = 200;
}
if (index != 200)
{
eingabe = eingabe.Insert(indexEingabe, Convert.ToString(info.KeyChar));
indexEingabe++;
}
if (indexEingabe > wort.Length)
{
index = 200;
}
} while (index < wort.Length && info.Key != ConsoleKey.Enter && info.Key != ConsoleKey.Escape);
if (index != 200)
{
score++;
}
} while (info.Key != ConsoleKey.Enter && info.Key != ConsoleKey.Escape && index != 200 && score != 1940588);
ende = true;
} while (ende != true);
if (score > highscore)
{
highscore = score;
}
if (score == 1940588)
{
Console.Clear();
Console.WriteLine("Herzlichen Glückwunsch!");
Console.WriteLine("Sie haben das Spiel durchgespielt und haben somit den Highscore geknackt.");
Console.WriteLine("Ihr Score war:\t" + score);
Console.WriteLine("\n\n");
Console.WriteLine("Ihr Highscore ist:\t" + highscore);
Console.WriteLine("\n\n");
Console.WriteLine("Möchsten Sie erneut spielen? true or false");
ende = Convert.ToBoolean(Console.ReadLine());
}
else if (info.Key != ConsoleKey.Enter && info.Key != ConsoleKey.Escape)
{
Console.Clear();
Console.WriteLine("Sie haben leider einen Fehler gemacht.");
Console.WriteLine("Ihr Score war:\t" + score);
Console.WriteLine("\n\n");
Console.WriteLine("Ihr Highscore ist:\t" + highscore);
Console.WriteLine("\n\n");
Console.WriteLine("Möchsten Sie erneut spielen? true or false");
ende = Convert.ToBoolean(Console.ReadLine());
}
else
{
Console.Clear();
Console.WriteLine("Vielen Dank für's mitspielen.");
Console.WriteLine("Ihr Score war:\t" + score);
Console.WriteLine("\n\n");
Console.WriteLine("Ihr Highscore ist:\t" + highscore);
Console.WriteLine("\n\n");
Console.WriteLine("Möchsten Sie erneut spielen? true or false");
ende = Convert.ToBoolean(Console.ReadLine());
}
} while (ende == true);
}
}
}
and an "Arduino Uno" Code
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,4,5,6,7);
void setup() {
Serial.begin(9600);
}
void loop() {
String wort;
wort=Serial.read();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(wort);
Serial.flush();
lcd.setCursor(0,1);
lcd.print("Score:");
lcd.print(score);
if (score==1940588)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Nice!");
lcd.setCursor(0,1);
lcd.print("New Highscore!");
delay(2000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Try again?");
}
else if (infoKey!=false)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Failure");
lcd.setCursor(0,1);
lcd.print(score);
delay(2000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Try again?");
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Thanks for playing!");
lcd.setCursor(0,1);
lcd.print(score);
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Highscore");
lcd.print(highscore);
lcd.setCursor(0,1);
lcd.print("Try again?");
}
}
I dont know how to tell the Arduino that he should read the variables word, score and highscore. Can someone telll me?
Thanks for your help