# Week 12: Interface Programming <a href="../index.html">Back to Home</a> I admit to doing the least possible work for this week possible. Luckily, I still managed to learn a bit - and I finally figured out my problem from Week 9 with the capacitance sensing (well, to a certain degree). ## Some Arduino issues Previously I had found that even though I set the baudrate to 9600, I had to set the serial monitor to 1200 to see proper numbers. It turns out that Arduino set the fuses in the Attiny44 wrong, so one has to click Tools -> Burn Bootloader to fix the issue. After that, not only did the serial monitor work at 9600, there was now a clear demarcation between the Tx and Rx pins being connected by a conductive material (e.g. human flesh) and non-conductive material (e.g. air, plastic). For the latter, the serial monitor would read -2; for the former, the readouts generally jumped to the thousands upon initial contact, then settle to somewhere around 60 or (more frequently) 30, and either stay there or decrease to 0 (though never to -2). The same pattern held for the dielectric sensing probe I made in Week 9, between dipping the inner tube into water such that the probes were sending electric signals across copper->plastic->water->plastic->copper. <embed src="images/probe.mp4"/> ## Interface Programming I wanted to just get Neil's txrx pyserial code working. It turns out the best way to figure out how Neil's code works is to 1) have Ben explaining lines of the code to you and 2) mostly re-writing it. It turns out that his code was waiting for a particular sequence of "framing bytes" before it started running - I didn't have that, so that was why the Tkinter GUI always froze when I tried to run the script. His serial output was also in a different format - using ser.readline() gave me the output as a str-type object, which had to be converted to an int. <img src="images/idle_code.jpg"/> In the end I had a much simpler idle function; I also ditched the health bar GUI and just went for simple display of "Conductive" and "Non-conductive" text. But at least now I have a basic understanding of how pyserial and Tkinter work. <embed src="images/conductivity.mp4"/>