The plan I used in developing my code

When I made my code I used some of the design choices I learned from earlier classes. However, most of what I did that lead up to my code was pretty random.

  • When I first started my code I planned to make a watch and I went to ask my subject’s what they thought. After talking to them, I received good information including on how they wanted an easier way of tracking a person’s splits and if the watch could help them improve with lap time recommendations.
  • At first, I wasn’t really sure on how to start my code and I had no idea on how to code a watch. Eventually over time I gave up and changed my idea.
  • My new idea was to create a code that showed the number of laps and the time of each lap for a student who passed the sensor.
  • To make my new code I first started making a code that turned out completely wrong. After this, I received help from my teachers who helped kickstart my code by explaining to me what I was doing wrong.
  • During this time I created multiple “test benches” and lines of codes that each represented a different part of my overall code. After I finished all the small parts, I brought them together and made one large code which I used as a frame to build on and make better after each and every test.

Stages of code

During the coding process, I made several “test benches” to test out and fix separate parts of my code. Each one shows a different level of when I used my code and what I built on.

BENCH FOR TESTING TIME DELAY CODE

import time

time1=time.time()
time2=time.time()

while True:
    time.sleep(2)
    time2=time.time()
    print(time2-time1)
    time1=time2

This code was tested to help make it so when a student passed the sensor, his/her time would show less chaotically and to help keep the sensor from tracking them multiple times.

CODE FOR FIGURING OUT HOW TO DEFINE EACH STUDENT ID

This code was used to help me figure out how to define each student as an individual and I was stuck on this for a long time before Mr. Lin helped me.

import time

cardId1 = "300833B2DDD9014000000014"
scanner = raw_input()
if scanner == cardId1:
print "good"
elif scanner != cardId1:
print "no"

cardId2 = "300833B2DDD9014000000013"
scanner = raw_input()
if scanner == cardId2:
print "good"
elif scanner != cardId2:
print "no"

scanner = ["cardId1","cardId2"]
print scanner

#studentname2 = "Hamlet"
#print (studentname == studentname2)



#
# CARDS = ['300833B2DDD9014000000014']
# len(['300833B2DDD9014000000014'])
#
# if CARDS == True:
#     print (time.strftime("%I:%M:%S, Philip"))
# else:
#     print "Wrong card"

MY FIRST FINISHED PROTOTYPE CODE 

This was an alternate version of my first final code as I lost the original. In this alternate one, I have changed the ID numbers with names and removed the code required for the sensor to detect the ID cards. The reason for this is because I did have a sensor and I could use this code without needing one. What this code does, compared to my current final one is that instead of tracking the time between laps (I didn’t know how to do this before) it just listed the exact time (hour, minute, second) when the card passed the sensor (or in this alternate, written down). This code was in my opinion, more user-friendly except it required using math to determine the time it took between laps. This is the code I built up from.

 

import time
from datetime import datetime


time = datetime.now()

lap1 = 0
lap2 = 0
lap3 = 0

cardId1 = "Philip"
cardId2 = "Jack"
cardId3 = "Charlie"
while True:
    scanner = raw_input()
    if scanner == cardId1:
        lap1 += 1
print str(lap1) + " Laps"
print str(time.hour) + " Hours"
print str(time.minute) + " Minutes"
print str(time.second) + " Seconds"
if scanner == cardId2:
        lap2 += 1
print str(lap2) + " Laps"
print str(time.hour) + " Hours"
print str(time.minute) + " Minutes"
print str(time.second) + " Seconds"
if scanner == cardId3:
       lap3 += 1
print str(lap3) + " Laps"
print str(time.hour) + " Hours"
print str(time.minute) + " Minutes"
print str(time.second) + " Seconds"

FINAL CODE

This is my final code and you can find parts of what I used in each stage inside it. The code here can track an individual’s laps and his time between laps. NOTIFY: Not all of my stages are in here, unfortunately, as I lost them over time.

import time
from datetime import datetime
import serial

ser = serial.Serial('/dev/tty.SLAB_USBtoUART',baudrate=115200) #defaults to 8N1

#ser.open()
#ser.isOpen()

# For each student added, simply repeat the code below.
# Each student requires two numbers. EX. Fourth student would be "time7 = time.time() and time8 = time.time()"
time1 = time.time()
time2 = time.time()

time3 = time.time()
time4 = time.time()

time5 = time.time()
time6 = time.time()

# Same as above, add a new lap with a new number for a new student
lap1 = 0
lap2 = 0
lap3 = 0

# Same as above, put in a variable(ex. cardId4) and make it equal to the cards ID

# After, adding the new lines for a new student above. Copy the paragraph starting with "if scanner == cardId2"

# Paste this underneath the last student "if scanner == cardId3"

# Change variables like "lap2 to lap4" and vice versa for "time" and change the "print 'Marley' to the student name

cardId1 = "1b390100110010603000300833b2ddd901400000000900b5"
cardId2 = "1b390100110010603000300833b2ddd901400000001400a8"
cardId3 = "1b390100110010603000300833b2ddd901400000000700bb"
while True:
    #time = datetime.now()
buffer = ser.read(ser.inWaiting())
    if (len(buffer)>0):
        scanner = buffer.encode('hex')
        if scanner == cardId1:
            lap1 += 1
print "Philip"
print str(lap1) + " Laps"
time.sleep(1)
            time2 = time.time()
            print (time2 - time1)
            time1=time2
            print "Lap Time"
#print str(time.hour) + " Hours"
            #print str(time.minute) + " Minutes"
            #print str(time.second) + " Seconds"

if scanner == cardId2:
            lap2 += 1
print "Marley"
print str(lap2) + " Laps"
time.sleep(1)
            time4 = time.time()
            print (time4 - time3)
            time3=time4
            print "Lap Time"
#print str(time.hour) + " Hours"
            #print str(time.minute) + " Minutes"
            #print str(time.second) + " Seconds"

if scanner == cardId3:
           lap3 += 1
print "Bob"
print str(lap3) + " Laps"
time.sleep(1)
           time6 = time.time()
           print (time6 - time5)
           time5=time6
           print "Lap Time"
#print str(time.hour) + " Hours"
           #print str(time.minute) + " Minutes"
           #print str(time.second) + " Seconds"

Final Product

After working on series of codes I have finally finished making it. I have made the code relatively short and simple in order for teachers or people to use it with only the requirement of knowing how to change numbers in the code needed. The code simply tracks separate Id cards(students) and tracks their number of laps and the time difference between them every time they pass the sensor. For example, Id number 556 runs past the sensor and the code will write down how many laps he has down and the number of seconds it took for him to reach the sensor. However, there are some problems with the code as it is. Due to lack of time I haven’t been able to optimize the code for huge classes, that require some more advanced organization of times and students in order to make it more user-friendly. So currently the code is better for smaller groups of runners or a single runner who wish to track the number of laps they can run and how long it takes for them to finish a lap.

1. Tracks number of laps and time of each lap for a runner

2. Lack of time, not optimized for large groups

3. Simple code for easy use

4. Could be more user-friendly

The code does have problems tracking slower students or students who pass at the same time due to the sensor having a large FOV and being sensitive.

FINAL CODE

import time
from datetime import datetime
import serial

ser = serial.Serial('/dev/tty.SLAB_USBtoUART',baudrate=115200) #defaults to 8N1

#ser.open()
#ser.isOpen()

# For each student added, simply repeat the code below.
# Each student requires two numbers. EX. Fourth student would be "time7 = time.time() and time8 = time.time()"
time1 = time.time()
time2 = time.time()

time3 = time.time()
time4 = time.time()

time5 = time.time()
time6 = time.time()

# Same as above, add a new lap with a new number for a new student
lap1 = 0
lap2 = 0
lap3 = 0

# Same as above, put in a variable(ex. cardId4) and make it equal to the cards ID

# After, adding the new lines for a new student above. Copy the paragraph starting with "if scanner == cardId2"

# Paste this underneath the last student "if scanner == cardId3"

# Change variables like "lap2 to lap4" and vice versa for "time" and change the "print 'Marley' to the student name

cardId1 = "1b390100110010603000300833b2ddd901400000000900b5"
cardId2 = "1b390100110010603000300833b2ddd901400000001400a8"
cardId3 = "1b390100110010603000300833b2ddd901400000000700bb"
while True:
    #time = datetime.now()
buffer = ser.read(ser.inWaiting())
    if (len(buffer)>0):
        scanner = buffer.encode('hex')
        if scanner == cardId1:
            lap1 += 1
print "Philip"
print str(lap1) + " Laps"
time.sleep(1)
            time2 = time.time()
            print (time2 - time1)
            time1=time2
            print "Lap Time"
#print str(time.hour) + " Hours"
            #print str(time.minute) + " Minutes"
            #print str(time.second) + " Seconds"

if scanner == cardId2:
            lap2 += 1
print "Marley"
print str(lap2) + " Laps"
time.sleep(1)
            time4 = time.time()
            print (time4 - time3)
            time3=time4
            print "Lap Time"
#print str(time.hour) + " Hours"
            #print str(time.minute) + " Minutes"
            #print str(time.second) + " Seconds"

if scanner == cardId3:
           lap3 += 1
print "Bob"
print str(lap3) + " Laps"
time.sleep(1)
           time6 = time.time()
           print (time6 - time5)
           time5=time6
           print "Lap Time"
#print str(time.hour) + " Hours"
           #print str(time.minute) + " Minutes"
           #print str(time.second) + " Seconds"

 

 

How code is working out

Currently, my code is working well except for two bugs I have found recently. The first being that I need to implement a timestamp as the sensor is detecting the card multiple times. Including, that when the sensor is activated the time might be wrong.

My code remains the same detecting the current time and number of laps and this is an example of my first code that was to make sure I could detect the difference between each individual card.

import time

cardId1 = "300833B2DDD9014000000014"
scanner = raw_input()
if scanner == cardId1:
    print "good"
elif scanner != cardId1:
    print "no"

cardId2 = "300833B2DDD9014000000013"
scanner = raw_input()
if scanner == cardId2:
    print "good"
elif scanner != cardId2:
    print "no"

scanner = ["cardId1","cardId2"]
print scanner

#studentname2 = "Hamlet"
#print (studentname == studentname2)



#
# CARDS = ['300833B2DDD9014000000014']
# len(['300833B2DDD9014000000014'])
#
# if CARDS == True:
#     print (time.strftime("%I:%M:%S, Philip"))
# else:
#     print "Wrong card"

The simple code returns an answer "good" if the right card is inputed and "No" if not. 
After I recieved some help I created this code which could tell the exact lap and current time when a student passed the sensor. 
This is my second code version.
import time
from datetime import datetime


time = datetime.now()

lap1 = 0
lap2 = 0
lap3 = 0

cardId1 = "Philip"
cardId2 = "Jack"
cardId3 = "Charlie"
while True:
    scanner = raw_input()
    if scanner == cardId1:
        lap1 += 1
print str(lap1) + " Laps"
print str(time.hour) + " Hours"
print str(time.minute) + " Minutes"
print str(time.second) + " Seconds"
if scanner == cardId2:
        lap2 += 1
print str(lap2) + " Laps"
print str(time.hour) + " Hours"
print str(time.minute) + " Minutes"
print str(time.second) + " Seconds"
if scanner == cardId3:
       lap3 += 1
print str(lap3) + " Laps"
print str(time.hour) + " Hours"
print str(time.minute) + " Minutes"
print str(time.second) + " Seconds"

This code returns the number of current laps per student every time they pass the sensor and lists the current time.
The coach or runners job is to then subtract the current times per lap and calculate their times per lap or overall time.
Finally, this is my current and present code which will be my final version once I finish adding timestamps and fixing bugs.
import time
from datetime import datetime
import serial

ser = serial.Serial('/dev/tty.SLAB_USBtoUART',baudrate=115200) #defaults to 8N1

#ser.open()
#ser.isOpen()






lap1 = 0
lap2 = 0
lap3 = 0

cardId1 = "1b390100110010603000300833b2ddd901400000000900b5"
cardId2 = "1b390100110010603000300833b2ddd901400000001400a8"
cardId3 = "1b390100110010603000300833b2ddd901400000000700bb"
while True:
    time = datetime.now()
    buffer = ser.read(ser.inWaiting())
    if (len(buffer)>0):
        scanner = buffer.encode('hex')
        if scanner == cardId1:
            lap1 += 1
print str(lap1) + " Laps"
print str(time.hour) + " Hours"
print str(time.minute) + " Minutes"
print str(time.second) + " Seconds"
if scanner == cardId2:
            lap2 += 1
print str(lap2) + " Laps"
print str(time.hour) + " Hours"
print str(time.minute) + " Minutes"
print str(time.second) + " Seconds"
if scanner == cardId3:
           lap3 += 1
print str(lap3) + " Laps"
print str(time.hour) + " Hours"
print str(time.minute) + " Minutes"
print str(time.second) + " Seconds"

Change of Project

My original plan for my lap tracking project was to create a slim watch that could track time. My plan went like this.

  • intro to programming plan
  • Program a watch that is lightweight and slim: Samsung Gear S
  • Set lap counters, and splits
  • Split time limits and recommendations
  • Beep when a lap is done
  • Beep twice when split is to be finished
  • Beep 4 times to pick up the pace
  • Beep once and pause and beep to slow down

I was going to do these steps one by one. However, this is way too complicated and I found that I was unable to do this. My new plan is to help make counting lap times for the mile run more accurate and simpler.  The coaches said they found it a nuisance trying to teach the students to use watches, not to mention from experience that some students don’t pay attention and when a student completes a lap their partner doesn’t time them properly. The new plan is to put sensors on the lap marker and making the students wear thin tags on their wrists or uniform.

When these students pass the sensor the tag activates it like an octopus card. Each tag will have their own individual number and when it passes the sensor the ID will be recorded down in a table with the exact time when the student passed, his number of laps (passes), and his name.

Unlike my original plan to create a watch which helped improve mile times, my new plan is to make the mile run more simple.

Plan for project

My original plan for this project was to make a watch that could track a person’s laps, time, and splits. However, this was too advanced for me and the school already has watches like this.  So I have changed to my plan to make a more simplified and lighter version of the watch for easier running.

My new idea acts like a type of octopus scanner. With the runner wearing a lightweight tag with a sensor. The idea is to be able to have a recorder that doesn’t require learning to use and is meant to be a very simplified version of the watch. It works by having the runner run past a sensor, this sensor then records the exact time he ran past it and it tracks that lap. By doing this the teacher will have an accurate number of laps run by each student making it harder for them to cheat and it will show the time difference between each lap.

Plan for coding

Individual sensor and people

when sensor activate by person

Tracks lap for the id: Records datetime

Repeat for each individual.

April Lap tracking project update

Since the start of the project, I have come up with two main designs. My first design was to create a clear plastic slim watch somewhat copying the new Samsung gear android watch design. It was designed off of this watch as I want the watch to be light and slim to help not obstruct the runner. So my original plan was to have this watch time how long someone’s lap was, and to count the number of laps someone did by tracking sensors that the watch passed.

After talking to my main clients, the middle school PE teachers I have come up with an entirely new design. Talking to them I have learned that they want the watch to also track splits and each lap individually. As well as to give recommended lap times and reminders to tell the wearer of the watch to run faster or slower.

Of course using all of these features would be too daunting and too complex for me. So my current plan is to figure out and learn how to code a timer and a lap tracker into a watch. As soon as I can figure that out I will see if I can do these other recommendations.

 

gear-s-black

April 7th 2016: Coding Sessions

For the last couple of lessons, we have gotten into programming and learning how to code python. The experience is a bit tedious and annoying, but I do enjoy being able to use what I’ve learned to create funny little moments.

What is currently working well for me is making little creations and having fun and using the basics. It is also extremely helpful being able to work in class as I can usually only be productive in a classroom.

 

Today we have also chosen our coding projects. These projects involve finding a problem and using coding to fix it. I decided to choose to use coding to help track the laps that students run in PE. In order to fix this, I came up with a few ideas, including a very slim and light watch that doesn’t slow down the runner in any way and tracks the number of laps by a sensor at the lap point. After running the required laps the watch will beep to signify the laps are done and will record the time taken.

March 16: Coding python

Today was the first intro to programming class back from Interim. This unit we are finally starting to learn to code and we are doing that by learning the basics of python on Codeacademy. To start off all that happened today was that we did two lessons, tip calculator and this structure lesson. These were to help understand how indents work and how to use math and create lines of code. Besides those two lessons, nothing else happened.

Backpack design Feb 19th 2016

In class, we were given a project to design and create a backpack during the class time. With my partner, we decided to create the “ican 9” designed to be simplistic, stylish, and easy to use. This project helped me understand what teamwork can achieve, and a bit more into how programming and design thinking can lead to great ideas. I also, saw excellent examples from my fellow peers, such as this groups “refrigerator backpack” that was designed with a flap and slot to place items in.

IMAG0649