//Alzubair Alshehhi //Fab2018 - Unity/Arduino/Attiny Project //Interfaces Week #include //Declaring a variable int data; //I used software serial because i am using a board with an Attiny microchip, //it doesn't have the Serial, you must use a library called softwareSerial SoftwareSerial myserial(0,1); void setup() { myserial.begin(9600); pinMode(7,OUTPUT); //Decalaring the pin 7 as output. } void loop() { // put your main code here, to run repeatedly: if(myserial.available()>0){ data = myserial.read(); //This will read the data from the Unity Serial Write if(data == 's'){ //checks if the Unity Serial Write matches 's' digitalWrite(7,LOW); //High and Low are sometimes the other way around, Switch them if needed } else{ // if Unity Serial Write doesn't Match 's' it will automatically go here digitalWrite(7,HIGH);//High and Low are sometimes the other way around, Switch them if needed } } }