Commit 670a0c65 authored by Jesse Eubanks's avatar Jesse Eubanks
Browse files

editing week14.

parent 8d3bfac2
Pipeline #237434 passed with stage
in 26 seconds
const int RLED = 1;
const int GLED = 2;
char comm;
void setup() {
void loop() {
if (Serial.available() > 0){
comm =;
if (comm == 'A'){
} else if (comm =='B'){
} else if (comm =='C'){
} else if (comm =='D'){
import serial
import tkinter as tk
import time
port = serial.Serial('COM3',9600)
def ronhandler():
def roffhandler():
def gonhandler():
def goffhandler():
def allonhandler():
def alloffhandler():
window = tk.Tk()
ronbutton = tk.Button(text="RED ON", command = ronhandler)
ronbutton.pack(side=tk.LEFT, padx=10, pady=5)
roffbutton = tk.Button(text="RED OFF", command = roffhandler)
roffbutton.pack(side=tk.LEFT, padx=10, pady=5)
goffbutton = tk.Button(text="GREEN OFF", command = goffhandler)
goffbutton.pack(side=tk.RIGHT, padx=10, pady=5)
gonbutton = tk.Button(text="GREEN ON", command = gonhandler)
gonbutton.pack(side=tk.RIGHT, padx=10, pady=5)
allonbutton = tk.Button(text="ALL ON", command = allonhandler)
allonbutton.pack(side=tk.BOTTOM, padx=10, pady=5)
alloffbutton = tk.Button(text="ALL OFF", command = alloffhandler)
alloffbutton.pack(side=tk.BOTTOM, padx=10, pady=5)
\ No newline at end of file
char message;
void setup() {
// put your setup code here, to run once:
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0){
message =;
if (message == '1'){
} else if (message =='0'){
import serial
import tkinter as tk
# setting up port
# port = serial.Serial('COM8', 9600) #####
# test LED
# port.write(b'0')
# port.write(b'1')
turns on led
def onhandler():
turns off led
def offhandler():
# create window
window = tk.Tk() # add arguments to adjust window
# create on button
onbutton = tk.Button(text="ON") # add arguments to adjust button
# onbutton = tk.Button(text="ON", command = onhandler) # add arguments to adjust button
onbutton.pack() # puts button on screen
# create off button
offbutton = tk.Button(text="OFF") # add arguments to adjust button
# offbutton = tk.Button(text="OFF", command = offhandler) # add arguments to adjust button
offbutton.pack() # puts button on screen
\ No newline at end of file
......@@ -124,7 +124,7 @@ p.agreement {
<h1>Group Work</h1>
<div class="img-with-text">
<img src="Images\network1.jpg" class="image" width="60%">
<img src="Images\network1.JPG" class="image" width="60%">
<i>Equation for spindal speed</i>
......@@ -114,23 +114,93 @@ p.agreement {
<h1><u>Week 14: Interface and Application Programming</u></h1>
<p>In this week for Interface and Application Programming we had a couple of tasks
ahead of us. As a group we set out to compare as many tool options as possible and
for our individual assignment we needed to write an application that interfaces a
user with a device that I made.</p>
<h1>Group Work</h1>
<p>For our group assignment we decided to look into different tool options that we could
have used during this week. The ones that we researched included:</p>
<li>MIT App Inventor</li>
<li>MATLAB GUI</li>
For this week most of the students in the lab used tkinder to create their individual
assignments. This is what we were demoed to use in the lab and it seemed pretty intuitive
so I continued to use it. This also worked out for me as I have a good amount of experience
in python. I also contemplated using Matlab GUI as I have a lot of experience with Matlab as well.
<div class="img-with-text">
<img src="Images\interfaceg1.JPG" class="image" width="60%">
<i>Equation for spindal speed</i>
<p>The spread sheet for our group work can be found
<a href="">HERE</a>.</p>
<p>When we first tried to use tkinder, we decided to test it out in a python shell in order to get comfortable with the commands.
to open a python shell we can simply type the following in the command window</p>
<p class="text-box">py</p>
<p>The first thing we can do next is type</p>
<p class="text-box">import serial</p>
<p class="text-box">import tkinter as tk</p>
<p>This will allow us to import the python libraires that we will need in order to
create the interface that we want</p>
<p>Next we will define a couple of functions that we want to activate</p>
<p class="text-box">def onhandler():<br>. . . port.write(b'1')</p>
<p class="text-box">def offhandler():<br>. . . port.write(b'0')</p>
<p>to be able to activate the commands we will need to make buttons so we can
actually interact with them. But before we can have buttons, we need to make a window</p>
<p class="text-box">window = tk.Tk()</p>
<p>To create button we can type out,</p>
<p class="text-box">onbutton = tk.Button(text="ON", command = onhandler)</p>
<p>And to actually place it on the window we type,</p>
<p class="text-box">onbutton.pack()</p>
<div class="img-with-text">
<img src="Images\interface1.JPG" class="image" width="60%">
<i>Equation for spindal speed</i>
<p>below is the result that comes from typing out all of the above commands.</p>
<div class="img-with-text">
<img src="Images\interface2.JPG" class="image" width="20%">
<i>Equation for spindal speed</i>
<p>When creating the individual assignment, we will actually want to write out and save
what we typed out. You can see that id did that in the Wing IDE for python down below.</p>
<div class="img-with-text">
<img src="Images\interfaceg3.JPG" class="image" width="60%">
<i>Equation for spindal speed</i>
......@@ -138,27 +208,86 @@ p.agreement {
<h1>Individual Assignment</h1>
<p>Because of some boards that I created not working much anymore I decided to create
an interface that would turn on and off some LEDs for my board from the electronics design week.</p>
<div class="img-with-text">
<img src="Images\interface3.JPG" class="image" width="60%">
<i>Equation for spindal speed</i>
<p>During the lab we basically only scratched the surface of what was possible in tkinder. One of the first things
that I wanted to do was create more space for my interface. To do this I increase my window size by typing,</p>
<p class="text-box">window.geometry("500x200")</p>
<p>This command changed my window to be about 500 x 200 pixels</p>
<p>Also, since I wanted four buttons in total, two to turn on and off the green LED, two to
turn on and off the red LED, and two to turn on ad off all LEDs. The only command that was a little different
was the ones that involved all the LEDs. First I imported the time library so that I could delay so that it could
print 'A' then 'C' into the serial instead of 'AC'</p>
<p class="text-box">import time</p>
<p>The new command I created looked like</p>
<p class="text-box">def allonhandler():<br>
. . . port.write(b'A')<br>
. . . time.sleep(0.05)<br>
. . . port.write(b'C')</p>
<div class="img-with-text">
<img src="Images\interface4.JPG" class="image" width="60%">
<i>Equation for spindal speed</i>
<p>Next I created a series of arguments to adjust exactly how I wanted my buttons to work. First I still had this
<p class="text-box">ronbutton = tk.Button(text="RED ON", command = ronhandler)</p>
<p>Here I'm making the button but to actually edit some of its features I typed out</p>
<p class="text-box">ronbutton.config(width=10,height=5,bg='red')</p>
<p>This changed the size of the button as well as the color.</p>
<p>This time, when I pack the button, I can type it out like this,</p>
<p class="text-box">ronbutton.pack(side=tk.LEFT, padx=10, pady=5)</p>
<p>The added arguments inside the pack command help me to position the button inside of the
<div class="img-with-text">
<img src="Images\interface5.JPG" class="image" width="60%">
<i>Equation for spindal speed</i>
<p>All in all, this is what my design for my interface ended up looking like. Below
you can see a video of it working in real time.</p>
<video class="image" controls autoplay loop>
<source src="interface.mp4" type="video/mp4">
Your browser does not support the video tag.
Lab Files:
<li><p><a href="lab_5.6.ino">Arduino File</a></p></li>
<li><p><a href="">Python File</a></p></li>
Individual Files:
<li><a href="interface.ino">Arduino File</a></li>
<li><a href="">Python File</a></li>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment