I made to make a GUI to communicate with my computer through serial port(USB). I programmed it in python using the Tkinter libray.
I wanted to control an LCD display and a hall effect sensor.
I started to create frames on the GUI where different parts will be placed.
Then I labed where to input the text for the LCD and where to display the value from hall effect sensor.
I wanted to use the PCB board I work on in output device, but it didn't work and I couldn't figure out the exact issue. I thought it was caused by badly clocking the microcontroller.
So I designed another board for the assignment where I include the crystal oscillator of 8Mhz, to see if the issue was caused by bad clocking.
But this board didn't work also from there I couldn't figure out what was the issue any more.
from tkinter import *
class Interface:
def __init__(self, master):
self.leftframe = Frame(master, height=300, width=70)
self.leftframe.pack(side=LEFT, fill=Y)
self.topFrame = Frame(master, height=70, width=350)
self.topFrame.pack(side=TOP, fill=X)
self.middleFrame = Frame(master, height=90, width=350)
self.middleFrame.pack(side=TOP, fill=X)
self.bottomFrame = Frame(master, height=140, width=350)
self.bottomFrame.pack(side=TOP, fill=X)
self.rectangleCanvas = Canvas(self.bottomFrame, height=50, width=250, bg='red')
self.rectangleCanvas.grid(padx=10, pady=45, row=1)
self.createVisualWidget()
def createVisualWidget(self):
self.LCD_label = Label(self.middleFrame, text="LCD Text", anchor=N)
self.LCD_label.grid()
self.LCD_entry = Entry(self.middleFrame, width=25)
self.LCD_entry.grid(row=1, column=0, padx=10, sticky=E)
self.send_button = Button(self.middleFrame, text="Send", takefocus=True)
self.send_button.grid(row=1, column=1, sticky=E)
self.northRect = self.rectangleCanvas.create_rectangle(0, 0, 180, 50, fill='blue')
root = Tk()
app = Interface(root)
root.title("Serial interface")
root.mainloop()
import serial
ser = serial.Serial('/dev/ttyUSB1', 115200, timeout=5)
ser.readline()
ser.write(b'hello')
ser.read(10)
ser.close()
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
SoftwareSerial mySerial(PB0, PB1);
LiquidCrystal lcd(5, 4, 3, 2, 1);
char msg[];
void setup(){
mySerial.begin(115200);
lcd.beging(2,16);
lcd.print("hello world");
delay(1000);
lcd.clear();
}
void loop(){
if (mySerial.available()){
while(mySerial.read() != 0){
msg = mySerial.read();
lcd.print(msg);
}
}
delay(100);
}
On this assignment I failed to make it work and I didn't get the reason why.
Files used can be downloaded Here