Interface & Application Programming


I got the code for interfacing fron https://processing.org/tutorials/electronics/#controlling-physical-media > code. I included a Serial.swap(1); to change the Tx & Rx ports to the alternative serial ports (port 2 & 3) as the LED and push button is already connected to the original serial ports. I added an extra code to off the LED whenever the button is pressed to help me when doing troubleshooting.
I connected the board to the programmer and uploaded the code to the ATtiny412. I pushed the button to check if the code has been successfully uploaded.
Next, i put the other code into Processing, another IDE software similar to Arduino IDE. I added a "COM12", into "port = new Serial(this, 9600);" to specify the port used.
I connected the Tx, Rx, Vcc, & GND pins of the ATtiny412 to the FTDI board and plug it into the USB port. After that, i run the code on the processing. Initailly, there was an error as it did not detect the board, but after adding the "COM12" i was able to run it.
I also realised i mixed up the Tx & Rx pins, after swapping the pins, the program works. When the button is not press the square is black in colour, but when the button is pressed it changes to grey.