With this code you will be able to blink LED1 when you push a graphical button. I use RPC and RTOS librairies on Mbed LPC1768. On python I use mbedRPC, and Tkinter.
Dependencies: mbed-rpc mbed-rtos mbed
Fork of Blinking_RPC by
GUI.py
- Committer:
- Thom_cass
- Date:
- 2017-07-30
- Revision:
- 1:589beced7ccc
File content as of revision 1:589beced7ccc:
# coding: utf8 #linux command to execute the script : python 'path'/RPC_test_code/GUI.py from Tkinter import * #GUI Librairie from mbedrpc import * #Libraire to link serial communication mbed <=> PC, (serial or http) mbed = SerialRPC('/dev/ttyACM0', 9600) #setup on the serial port ACM0. #You can check what port you are using with a linux shell command : ls /dev/ttyACM* #9600 : default baudrate #------------RPCvariable Blink = RPCVariable(mbed,"Blink_RPC") #Create a new variable : name= Blink_RPC, on the mbed setup before, link to the mbed variable Blink #--------------GUI display root = Tk() #creation a new window root.title('Blinking led') #display title root.geometry('150x50+200+200') #Set geometry of root window Area = LabelFrame(root,text = "Blinking mode : ") #area creation Area.pack(fill="x",expand="yes") #--update function def update(): if(var.get() == 0): Blink.write(1) #change Blink_RPC value on mbed print 'Blinking' #Linux terminal output var.set(1) #change var value for the next clic else: Blink.write(0) #change Blink_RPc value print 'No blink' var.set(0) #---------------------------create a simple button var = DoubleVar() var.set(0) Blink_button = Button(Area, text="Blink", command = update) #command = update => call function update() when you clic button Blink_button.pack() root.mainloop()