Course Track

Code:

# Function RobotC

So we today we learned about functions

______ (Function name) = (t)

run1m (t) (how to run functions)

Count statements     =   int count = 0 (Set count to 0 to make it more accurate)

int = integer

at the end write count = count+1 (Add count)

To run write at the buttom task main()

{Function name

snake();

}

# Shaft Encoder Notes

Shaft Encoder: A digital system that measures the amount of rotation on the axle which passes through the sensor.

-The number of count for one rotation is 360

• One rotation is around 29-30 cm
• The box measurements are
• 126 = 4.26 (revolutions)
• 147 = 4.98 (revolutions)
• 131 = 4.44 (revolutions)
• 150 = 5.08 (revolutions)

-You do not need to touch the Pragma statement

-Sensors names can be named whatever you want as long as it

1. Doesn’t contain any spaces
2. No special names such as \$, %, &
3. Not already used by ROBOTC

-Must be plugged into any adjacent DIGITAL ports

1. Go to motors and sensors setup
2. Name the dgtl

-Always clear the encoder values by setting it to zero, this way the encoder can accurately move a certain distance

-The while loop command is used to control when the loop should end and the body of the code that is loop

• The main purpose of the while loops  > (less than) is that the robot will continue to count until it counts to whatever number you told it to go
• It checks the condition before it runs the code between the curly braces and then checks it again after each time it runs the code between the curly braces.

Sensor debug window

• Provides real-time information on the values of all the sensors configured on the robot
• ROBOTC must have a connection with the robot for the sensor debug window to work, it is the only way to communicate with the computer

-There is no way to change the distance of the robot travels other than changing the number of counts on the encoder

cont…

# Hebocon (F)

What is a Hebocon?

A Hebocon is first off, a robot, but more then anything else it has to be ugly.

What parts did you build your Hebocon with? Did you make any improvements to it outside of class?

I didn’t add any improvement outside of class, however, I did add a ‘unicorn horn’ to add some character to my robot.

What worked? and what didn’t work?

Well, I removed all the batteries to the skateboard so that the robot would be lighter and in turn can push this a lot further and faster.

What would you change next time?

Next time I would change my robot completely, as it seemed the bigger robots had more success.

Include an image and a short video to help the audience visuallise the event.

# Thursday 18th January – Cover lesson

In today’s class, we watched the first 40 mins of the Short Circuit! This movie gave us an inside look at what would happen if the world had a fully aware robot able to chart EQ. This movie is a good representation of how our world is run by technology.

Quiz: 9/10

Well in today’s day in age technology is so advanced that we program it for minimal tasks such as opening a drawer or shuffling cards, that being said I would have a robot that would do my homework. As a kid this was a dream of mine, it posed too many positives for someone to not create. If someone did create such a robot I wouldn’t have to worry about doing homework such as Chinese that would normally take hours.

So in the movie above a robot does what a robot is programmed, it does not possess a testable EQ. Therefore it would need to have a processor that is able to input ‘inputs’ and ‘outputs.’ This homework robot would probably also need to have a camera so that it can analyze the problems to answer them.

# Final Project (S)

Questions

So for our final project, we wanted decided to make a taxi calculator. I sporadically see my self-questioning if I have enough money to pay for the taxi and still have leftover money for food. With this taxi calculator, it can finally answer the question of how much it will cost for a certain distance covered by the taxi. My partner and I will be using python to code this taxi calculator program. Taxis in Hong Kong is very easy to access and is extremely helpful if you want to go certain places in hong kong. However, before all of this, we used our knowledge with design thinking and learned that this app needs to be tailored to the user, and not the programmer. We created ten questions that will give us a good first step into how to code this. With these questions, we were able to better understand the user’s needs and how to meet them as programmers.

1. Do you use Taxis often?
2. Do you like Taxis?
3. Would you want a taxi calculator?
4. Do you prefer taxis or other forms of public transport?
5. Would you want your measurements to be in meters (M) or Kilometers (KM)
6. Do you like math?
7. Do you use the red, blue, or green taxis more often?
8. Would you want to know beforehand how much your taxi costs?
9. Do you feel that taxi’s sometimes overcharged you?
10. How would you like the interface to work?

Psuedo Code and Flow Chart

So when making our pseudocode and flowchart we tried to tailor it to the user’s needs. The questions above really helped make the flowchart extremely easy, because we knew exactly what the user’s wanted and needed. With the 20 responses we got, most of them wanted a clear, precise, and wanted it to get to the point.

pseudo code

1. Ask for current location (if there is no way to sense the user’s location)
3. Ask which taxi to use (red, green, blue)
4. Calculate price
5. Display Price

Flow Chart

Design Thinking Sentence

This is targetted to people who use taxi’s regularly but want to know the price of the taxi beforehand.

Questionnaire

Code

```import math
def RedTaxiCounter(meters):
if meters <= 2000:
return (24)
over=meters-2000
times=over/200
times=math.floor(times)
extra=times*1.6
return(24+extra)

def BlueTaxiCounter(meters):
if meters <= 2000:
return (18.5)
over=meters-2000
times=over/200
times=math.floor(times)
extra=times*1.4
return(18.5+extra)

def GreenTaxiCounter(meters):
if meters <= 2000:
return (17)
over=meters-2000
times=over/200
times=math.floor(times)
extra=times*1.4
return(17+extra)
while math:
choice = input('what color taxi are you taking today?'
'\n'
'1 = red'
'\n'
'2 = blue'
'\n'
'3 = green')
if choice == '1':
global meter
length=float(input("How long was your trip in km?"))
length=float(length*1000)
print('The price of your taxi will be around')
print ("\$" + str(RedTaxiCounter(length)))
quit()
if choice == '2':
global meter
length=float(input("How long was your trip in km?"))
length=length*1000
print('The price of your taxi will be around')
print ("\$" + str(BlueTaxiCounter(length)))
quit()
if choice == '3':
global meter
length=float(input("How long was your trip in km?"))
length=length*1000
print('The price of your taxi will be around')
print ("\$" + str(GreenTaxiCounter(length)))
quit()
else:
print('Try again')
```

GUI

```from tkinter import *
from tkinter import ttk

root = Tk()

frame = Frame(root)

labelText = StringVar()

def Text():
print("Micah is fat")

label = Label(frame, text="Welcome to the Taxi Program!")
Calculate = Button(frame, text="Calculate Fare", command= Text)
RedTaxi= Button(frame, text="Red Taxi", fg="orange red")
BlueTaxi= Button(frame, text="Blue Taxi", fg="navy")
GreenTaxi= Button(frame, text="Green Taxi", fg="forest green")
Quit= Button(frame, text="Quit", command=quit)

label.pack()
RedTaxi.pack()
BlueTaxi.pack()
GreenTaxi.pack()
Calculate.pack()
Quit.pack()
frame.pack()

root.mainloop()```

This project has really propelled my understanding of python, in this project I was able to use functions, if statements, and while loops. Compared to my first project I where I only used If and while loops. I can now use functions easily, in addition, able to use global functions, and now import maths.

# Makey Makey with Balance Board Challenge

So for this project, we were meant to code from scratch first, and by using the basis from scratch we would code to it back to pycharm either using Tkinter or pygame. In short, my partner and I were not able to complete this task as it proved much too difficult. Even so, we learned valuable lessons on the way. Even though we rarely use this form of block coding, its efficacy was known, scratch really helps when you are trying to get your thoughts down on paper. Instead of having to code it all and spending hours to see if it works, scratch is a much easier way to code and it very straightforward. Once your scratch code works, you can use that as your pseudo code.

Video:

Audio:

As I said before we weren’t able to code it into python, but I gained new knowledge. The first is what GUI is, it stands for Graphical User Interface, basically, it lets creates the image that the coder needs it to show. This will prove important later on in the future as its instead of just texts showing up I can have an image show up on my screen. And just like the block codes above, you can assign certain functions to certain keyboard sequences.