BACK

Week 13 - Interface and Application Programming


Tuesday afternoon - I have made a python-based GUI (using tkinter) to control the bipolar stepper motor from my last assignment. I would like to try making a phone app next.




1. USB serial communication/Python-tkinter GUI


1. USB serial communication/Python-tkinter GUI


Since I was using many jumper wires for the first time (I connected the FTDI cable to GND,MOSI,MISO pins on the pin header for ISP), I was feeling unsure about the whole exercise all the time and kept checking the connections every now and then.

I wrote this code in Arduino IDE and flashed it into the ATtiny44 on my board. I tried if the serial communication is happening using Arduino serial monitor. It did. When 'c' was typed and sent, the motor rotated clockwise and did the opposite direction when 'a' was sent.

I wrote this python code, importing tkinter and pyserial. It was a good experience figuring out how to write this code. I learnt about the role of the period operator in object-oriented programming to understand classes and functions. I also read about 'button' and 'pack' operations in tkinter.

After a lot of debugging (including soldering bugs!), the programme worked and I whooped in joy when the motor obeyed the GUI.

Free HTML5 Bootstrap template
1. Arduino code to check serial communication
Free HTML5 Bootstrap template
2. Receiving data from ATtiny44 on the PCB.
Free HTML5 Bootstrap template
3. Python code for the graphical user interface and serial communication with the stepper motor.
Free HTML5 Bootstrap template
4. Command to execute the python file and communicate with the USB port.
Free HTML5 Bootstrap template
5. One of the dozen errors that had to be debugged before the Python file worked. This one is asking me to encode the character sent to the chip.
Free HTML5 Bootstrap template
6. The GUI. Press 'clockwise' to rotate the motor by 11 steps in the clockwise and 'anti-clockwise' for the opposite direction.

BACK