# Arduino Files for hacking HomeScope's XY axes Here we can find files with code to understad the Arduino XY code ## Move a single Servo motor Servo motors are the engines of the XY robot used by HomeScope to move the biological samples is the focussed XY plane Here we can find a file with very simple code to move a single **Servo motor** > `move_single_servo.ino` ## Read JoyStick values The JoyStick of HomeScope can be used to communicate movement wishes to the XY robot. For this we first need to know how to read the analog values. A very simple example of this is to just send the analog input values to the Serial port. > `Joystick_values_to_Serial.ino` ## To move or not to move: send message with JoyStick As the analog values of the JoyStick input are several, we can discretize the possible input by defining a threshold of deflection. Once the Stick is bended beyond it can be interpreted as a message to move in a given direction. A simple code to implement this is: > `Joystick_to_Serial_move_or_not.ino` ## Print mesage (XY coordinates?) to an LCD display To Print a message to an LCD display using i2c protocol, the default library to achieve this is the `LiquidCrystal_I2C` by Frank de Brabander. In the Arduino Environment the library is called `LiquidCrystal_I2C.h` For more on this library see: https://www.arduino.cc/reference/en/libraries/liquidcrystal-i2c/ The simplest code to write a message is: > `LiquidCrystal_I2C_Frank_de_Brabander.ino` **However**, the XY robot uses the `Servo` library and it is imcompatible with it. For this reason **we use** the `LiquidCrystal_I2C_Hangul` library authored by Junwha Hong, Dohun Kim, and HyungHo Kim **instead**. Not all Liquid Crystal i2c libs are compatible so make sure you are using this one. The XY robot can print coordinates to an **LCD display** using an **i2c controller**. The controller is usually located behind the LCD and it is sadder to the LCD's pins This way we only need two GPIOs to transmit messages In the Arduino Environment this library `LiquidCrystal_I2C_Hangul.h`. For more info see: https://www.arduino.cc/reference/en/libraries/liquidcrystal_i2c_hangul/ The minimal code to write to the LCD is: > `LiquidCrystal_I2C_Hangul.ino` You can play with this code, and now putting all togther, and adding a **2-state machine** structure to the code, we can now understand the code files listed in the [Arduino XY repository](https://git.xinstitute.org.cn/Biology_Laboratory/Arduino_XY)