Electronic
I use my board and connect to my board one button.
My board have a Atmega328.
Arduino
To program my board i use a Arduino IDE. First in my code i put the position pin is my button in my case is Ditial 7. In the setup i say the my button is a input and i open the serial port 9600. In the loop i write if my button is on i serial write 1 and and if is off i serial write 0.
Processing
In Processing i open the port to receive the value from my board.
In setup i give the size of my window and open serial port. In draw i write if read in serial 0 the background of my window is white
if read in serial 1 the background is gray.
In this video i show the example i make.
Test other code
In this code the app send the values to the microcontroler. In this case if the mouser is in the window gray the stepper motor move to the rigth if the mouser is out the window the step motor move to the other side.