100% found this document useful (1 vote)
23 views

Arduino Handbook

This document provides a guide to using Arduino. It introduces basic concepts like input/output pins, data types, conditionals like if/else statements, loops like for and while, and functions. It also covers sending data from Arduino to Processing for visualization and plotting. The guide is divided into sections covering topics like the Arduino setup, basic programming structures in Arduino, and functions for performing common tasks.

Uploaded by

Arun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
23 views

Arduino Handbook

This document provides a guide to using Arduino. It introduces basic concepts like input/output pins, data types, conditionals like if/else statements, loops like for and while, and functions. It also covers sending data from Arduino to Processing for visualization and plotting. The guide is divided into sections covering topics like the Arduino setup, basic programming structures in Arduino, and functions for performing common tasks.

Uploaded by

Arun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

A guide to Arduino: ENME351 (Electronics II)

Abdelrahman Hammad

April 29, 2016

4
Contents
1 Memo 1

2 Cover Letter 3

3 Preface 7

4 So what is an Arduino? 8

5 Bare Basics 9
5.1 void setup() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.2 void loop() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.3 Analog Versus Digital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.4 Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.4.1 Input Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.4.2 Output Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6 Data types 11
6.1 int . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.1.1 Digital data as integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.2 float . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.2.1 Analog data as floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.3 strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.4 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.5 Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.6 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

7 Conditionals 13
7.1 if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.2 if......else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.2.1 if......else if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.3 Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.4 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

8 Loops 14
8.1 for loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
8.2 while loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
8.3 Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
8.4 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

9 Functions 16
9.1 Function structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
9.1.1 Return type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
9.1.2 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
9.2 Using the Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
9.3 Make your own function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
9.4 Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
9.5 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5
10 Good Functions you need 17
10.1 I/O operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
10.1.1 pinMode() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
10.1.2 digitalRead() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
10.1.3 digitalWrite() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
10.1.4 anaolgRead() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
10.1.5 analogWrite() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
10.2 delay() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
10.3 Serial.print() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
10.4 millis() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

11 Processing 19
11.1 How to send data to processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
11.2 How to receive this data ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
11.3 Formatting correctly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
11.4 Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

12 Addendum 20
12.1 Surveys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

13 Usability test results 22

14 bibliography 23

List of Figures
1 Example of some code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Example of an arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Every code’s bare minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 Example of variable use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5 Example of an if-else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6 Example of for loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7 Example of function use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
8 Example of Simple Processing Code . . . . . . . . . . . . . . . . . . . . . . . . . 19
9 Coding platforms used by 35 Students before ENME351 . . . . . . . . . . . . . . 20
10 Coding Experience of 35 students before ENME351 . . . . . . . . . . . . . . . . . 21
11 Coding time of 35 students during ENME351 . . . . . . . . . . . . . . . . . . . . 21
12 Opinion of 35 students on manual for ENME351 . . . . . . . . . . . . . . . . . . 21

List of Tables
1 Which pin does what input ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2 Which pin does what output ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6
3 Preface
Figure 1 shows a very basic example of sample code of Arduino.
This is what is expected of students to be able to do to succeed
in the class.
I plan to present the required information as follows:
Present a good summary of all the tools you will have at your
disposal. This will be brief and won’t explain how to use them, I
do that instead throughout the manual. 5 → Explain Data types
in section 6 → Explanation of conditionals and loops in section
7 and 8 → Explanation of functions in section 9 → Explanation
of good function to use in section 10→ Explanation of processing
in section ??.
Furthermore each section will either have good examples or ac-
tivities that tie the concepts used in the electronics lab.

Figure 1: Example of some


code

7
4 So what is an Arduino?

Figure 2: Example of an arduino

The best way to understand an Arduino is to consider a human brain, because in essence it
is a brain too. Your brain constantly receives signals from its environment sent by your senses
all over your body. This data is then analyzed and when necessary the brain then produces
an output in the form of your body moving. For instance when you accidentally touch a hot
stove, your brain receives input from your fingers which causes output in the form of your hand
moving away. If you understood that, then you now understand what an Arduino is.

Arduino is an open-source prototyping platform based on easy-to-use hardware and


software. Arduino boards are able to read inputs - light on a sensor, a finger on
a button, or a Twitter message - and turn it into an output - activating a motor,
turning on an LED, publishing something online. You can tell your board what to
do by sending a set of instructions to the micro controller on the board 1

As seen in figure 2 the Arduino has many different pins, with many different labels. Here is
how they break down:
Input: Those are all the pins with A before them.
Output: Those are all the pins from 0 all the way to 13
Power: All other pins are power related for powering up your circuit

1
According to arduino.cc

8
5 Bare Basics

Figure 3: Every code’s bare minimum

As seen every Arduino code you will write will always have two blank function. Figure 3
shows an example of what you are given to start. The setup function and the loop function.

5.1 void setup()


The setup function runs only one time. Like the name states, it is used as to setup our Arduino
program.

void setup () {
Once the Arduino program is set up, this code block is run only once
}

5.2 void loop()


The loop function runs infinitely.

void loop () {
Anything in this code block runs as long as the Arduino is running
}

5.3 Analog Versus Digital


Two things you need to understand the difference between is Analog and Digital forms of data.
Digital Data is discrete, while Analog data is continuous.
To further illustrate:

Digital data is either HIGH or LOW regardless of inputting or outputting a value. Noth-
ing else no in betweens.
Input: 0 or 1 (Which is the same as LOW or HIGH)
Output: 0 or 1 (Which is the same as LOW or HIGH)

Analog data on the other hand is usually a continuous range, and also depends on wether
we are inputting or outputting.
Input: 0 - 1023, ex:2.0, 5.7,999.9,438.8,1023.0,0.0, 1 1034.7, -9.8
Output: 0 - 255 ex:2.0, 5.7, 0.0, 255.0, 277.9, -10.9

5.4 Input and Output


Inputs and outputs are the heart of almost all the Arduino Labs. In almost all Arduino applica-
tions you will definitely need to use some form of either input or output and its very important
to understand how to do that. Before I explain how to actually code them, familiarise yourself

9
with which pins serve as outputs and which pins serve as inputs using table 1 and table 2
respectively.

5.4.1 Input Pins


Here’s a table that summarises which pins you should use when thinking about reading values.
As you can see in table 1, Everything on the right hand side can be used to read Digital data,
while everything on the left hand side of the board is used for Analog data.

Table 1: Which pin does what input ?

Input
Pins that have Digital input Pins that have Analog input
0,1,2,3,4,5,6,7,8,9,10,11,12,13 A0, A1, A2, A3, A4, A5

5.4.2 Output Pins


Output however has different pin specifications

Table 2: Which pin does what output ?

Output
Pins that have Digital output Pins that have Analog output
0,1,2,3,4,5,6,7,8,9,10,11,12,13 3,5,6,9,10,11

10
6 Data types
Before learning how handle input or how we make motors move, it is essential to learn how
data is manipulated. There are three important types of data needed for this class: int float
string.These data types are essential and they should be like your name.

6.1 int
An integer is any number x ∈ the set of real integers Z. That is
in other words it has to be a number with no decimal place.
Examples: 5, 6, 7, 8, 1023, 0, -4, -3

6.1.1 Digital data as integers


Since now we know x ∈ the set of real integers Z, we also now
digital data is either 0 (LOW),1(HIGH) which also ∈ the set
of real integers Z. Therefore we can say: Digital data is can be
represented by an int.

6.2 float
A float is any number x ∈ the set of real numbers R. That is in
other words it has to be a number with a decimal place.
Examples: 5.2, 2.6, 7.0, 8.9 , 1023.1, 0.0, -4.2

6.2.1 Analog data as floats


Since now we know x ∈ the set of real numbers R, we also now Figure 4: Example of vari-
that analog data can be represented by any number between able use
either 0 - 255 or 0 - 1023 which is also ∈ the set of real numbers
R. Therefore we can say: Analog data can be represented by a
float.

6.3 strings
A string is a combination of characters such that each char-
acter c ∈ Anything. That is in other words it can be
letters, numbers, strange symbols, anything.
Examples: ”hello”, ”I have 3 cats”, ”I have $3 in my bank account”, ”123”

6.4 Variables
Arguably the best thing about coding: Variables. Variables is something like human memory.
You associate a memory with something. For example, soccer. Soccer is a sport that you like to
play. So your brain would file it in this form; Sport soccer = fun. Sport is the type of activity,
soccer is the activity name, and fun is what your brain remembers about it.

Now let’s use Variables:


(int / float / string) x = 4 → int x = 4. Your Arduino brain now knows x is 4
(int / float / string) x = HIGH → int x = HIGH. Your Arduino brain now knows x is HIGH
(int/ float/string) x = 4.0 → float x = 4.0. Your Arduino brain now knows x is 4.0

11
(int/float/string) x = ”Hello” → string x = ”Hello”. Your Arduino brain now knows x is ”hello”

6.5 Activity
1. Is 4 an int or a float or a string ( Int / float / string )

2. Is 4.0 an int or a float or a string ( Int / float / string )

3. Is ”4” an int or a float or a string ( Int / float / string )

4. Is ”4.0” an int or a float or a string ( Int / float / string )

5. Is this Valid: x = 5 (Yes / No)

6. Is this Valid: float x = 5 (Yes / No)

7. Is this Valid: string x = ”This is correct” (Yes / No)

8. Create a variable that has the ability to store Analog data

9. Create a variable that has the ability to store Digital data

6.6 Solutions
1. int

2. float

3. string

4. string

5. No, Missing Identifier

6. No, wrong data identifier. Either change to int x = 5 or float x = 5.0

7. Yes

8. float x

9. int x

12
7 Conditionals
7.1 if
The if statement is one of the most powerful control statements
in Arduino. The best way to think of it is as a traffic light.
Imagine you’re driving down route one. You see a traffic light
ahead. Then you do an evaluation, and IF the light is green you
go ahead.

7.2 if......else
If else is probably used when you have many different possible
scenarios and not necessarily just two. Lets use the traffic light
example on more time. You see a traffic light ahead. Then you
do an evaluation, and IF the light is green you go ahead, ELSE
stop.

7.2.1 if......else if
Figure 5: Example of an if-
A more advanced control statement is when you nest an if inside else
an else to cover more cases. Once again lets use the traffic light
example. You see a traffic light ahead. Then you do an evalua-
tion, and IF the light is green you go ahead, ELSE IF the light
is yellow then be careful ELSE Stop. You have no covered all
the cases of a traffic light. Refer to figure 5 to see how the code should look like.

7.3 Activity
1. Assume that I have a int variable called input. This input has a value of HIGH. I run
this code on it:
String answer;
if (input == LOW) { Note: == Checks for equality
answer = ”Output 1”;
} else {
answer = ”Output 2” ;{
}

2. Assume that I have a float variable called input. This input has a value of 45.7. I run this
code on it:
String answer;
if (input > 49) { Note: == Checks for equality
answer = ”Output 1”;
} else if (input ¡ 40){
answer = ”Output 2” ;{
} else{
answer = ”Output 3” ;
}

13
7.4 Solutions
1. Output 1
2. Output 3

8 Loops
Loops in a nutshell is like the gym teacher who mad you run lap every time he saw you. The
best way to explain this is to model the coach’s orders in an Arduino loop.

8.1 for loop


A for loop in very simple. It has a simple for-
mat:

for( Variable to be used; Condition; Change to make to vari-


able each time ){

First lets implement the track example where the coach wants
you to run 10 laps in a basic english format.

for( Current lap is 0; Current lap is less than 10; Increase current
lap by 1 ){
Sweat a lot in between
} Figure 6: Example of for
loop
Now we need a checklist to convert this english statement into
executable Arduino Code:

1. We need to identify our variable type. Since we know laps is a discrete number (i.e.
0,1,2,3) we should use an (int / float / string) variable. int CurrentLap = 0

2. We need to convert our condition to an expression for Arduino to evaluate. You need to
use one or more of the following <, =, > operators to achieve this. CurrentLap < 10

3. We also need to convert our final the change we want the Arduino to make to our variable
to an expression that can be evaluated. CurrentLap = CurrentLap + 1

In the end it should look something like the following:

for( int CurrentLap = 0; CurrentLap < 10; CurrentLap = CurrentLap + 1){


Sweat a lot in between
}

8.2 while loop


While loops have a much simpler format:

14
while(expression ){
}

Now let’s do our example in a while loop format. While loops are a lot simpler because you
only place the expression in as a parameter

int CurrentLap = 0 ;
while(CurrentLap < 10 ){
CurrentLap = CurrentLap + 1;
}

8.3 Activity
1. If you know you want to iterate over a list a certain number of times which is better ?
(For Loop/ While Loop)

2. What will this piece of code do


for (int row = 1; row < 10; row ++){ Hint: ← row ++ is the same as row = row + 1
for (int col = 1; col < 10; col ++){
System.out.print(row*col);
}
Serial.println(””); Hint: ← That just prints a new line
}

3. How many times is hello printed ?


int counter = 0;
while(counter < 5){
Serial.println(”Hello”);
}

4. How many times is hello printed ?


int counter = 0;
while(counter < 5){
Serial.println(”Hello”);
counter++;
}

8.4 Solutions
1. For, because while are usually used when we don’t know how many iterations are gonna
occur before our condition is met

2. Prints the multiplication table

3. Never stops working, prints hello infinite times because were not increasing our counter

4. 5 times

15
9 Functions
Functions play an extremely important role in making Arduino coding very easy.

9.1 Function structure


Functions are structured as follows:
Return Type Function Name Parameters
Lets look at an example that you’ve seen many times:
void setup ()
1. void → Void means it returns nothing

2. setup → The name of this function is setup

3. ()→ Since there is nothing in the parentheses, this means that this function takes no
parameters

9.1.1 Return type


The best part way to think of the return type is to think of those time your mom sends you to
the grocery store to get one thing. Needless to say how much trouble you’d be in if you don’t
get that exact thing. This is the same exact thing. Once you set the return type of the function
to a certain type, Arduino now expects it to be returned.

9.1.2 Parameters
Parameters is just what you pass in to a function as its inputs. A prime example is if you try
to make cereal. I am 99 percent positive you can’t make cereal without milk and the actual
cereal. This specific task requires milk and cereal to make. Using everything we’ve discussed
lets do an example in simple english format.
Bowl Of Cereal cooking (Dairy x, Cereal y)
mix x and y
return Bowl of Captain Crunch
Note that parameters are first entered as variables (refer to section 6.4 for variables).

9.2 Using the Function


Using the function is a little different than defining a
function. The best way to explain this is probably
through an example. Lets try to make a very simple
function that doubles an input number given too it. As
you can see I defined a function called ’doublemyvalue’
in figure 7. Now that we have a defined function here’s
how to use it.
1. Call the function by its name

2. Enter a parameter with a type that matches its


signature

3. Set an external value that receives the returned


value from the function

16

Figure 7: Example of function use


As you can see in figure 7, I called doublemvalue by
its name. I then passed the required input parameter
which is just an int variable called ’original value’. I
then have a catcher variable called ”new value” which
receives the value returned by the function doublemy-
value.

9.3 Make your own function


Functions are powerful and they help you reduce redun-
dant code. You can make any function you want as long as you stick with these principles:
1. Know your return type
2. Know what you will name the function
3. Know what parameters you need
4. Always return a value Except if you have a return type of void.

9.4 Activity
1. What is the return type of the following function ? What about its list of parameters ?
String testfunction () {
2. What is the return type of the following function ? What about its list of parameters ?
float testfunction (float a) {
3. Given the following signature : int testfunction (int a){ . Would the following calls be
valid ?
int y = testfunction(4.2) (Valid / Invalid)
float y = testfunction(4) (Valid / Invalid)
int y = testfunction(4) (Valid / Invalid)

9.5 Solutions
1. Returns a string, and has an empty list of parameters.
2. Returns a float, and takes one float as a parameter.
3. Invalid, Invalid, Valid

10 Good Functions you need


10.1 I/O operations
10.1.1 pinMode()
If you look at figures 1 and 2, you’ll notice that many pinsa re capable of both input and output.
This is where pinMode() comes into play. It tells you Arduino which pin is inputting data and
which pin is outputting data. Example would look something like: pinMode(11, INPUT);
Key things to note:
1. No need for a variable to receive anything since there is no return (Refer to section 9.2).
2. List of parameters is an int variable and either INPUT or OUTPUT, where the int value
represents the pin number

17
10.1.2 digitalRead()
digitalRead() → input → Reads HIGH or LOW → Return type of int (Refer to section 9.2)→
requires pin number as parameter. Example: int value = digitalRead(11)

10.1.3 digitalWrite()
digitalWrite() → output → Send HIGH or LOW → Return type of Void (Refer to section 9.2)→
requires pin number as parameter, and whether you want to send HIGH or LOW. Example:
digitalWrite(11,HIGH)

10.1.4 anaolgRead()
analogRead() → input → Reads between 0 and 1023 → Return type of float (Refer to section
9.2)→ requires pin number as parameter. Example: float value = anaolgRead(11)

10.1.5 analogWrite()
analogWrite() → output → Send HIGH or LOW → Return type of Void (Refer to section 9.2)→
requires pin number as parameter, and the value you want to send which has to be between 0
and 255. Example: anaolgWrite(11,144.4)

10.2 delay()
delay() is probably one of the most important functions you will use. It has a return type of
void. It has a parameter list of one integer. Remember how we said in section 5.2 that the
loop() function just keeps on going and going forever. Well sometimes you want to stop taking
reading or stop outputting readings. delay() is your tool. It holds the program on pause for as
many millseconds as you input it. So let’s say I want a 5 sec pause in my program then I can
simply just say delay(5000);. Once the inputted integer must be in terms of milliseconds and
not seconds.
Key things to note:
1. No need for a variable to receive anything since there is no return (Refer to section 9.2).
2. Input should be an int in the form of milliseconds
3. Program is suspended for the inputted value of microseconds

10.3 Serial.print()
Serial.println() helps you visualise values that you are getting. Its your built in, unlimited ink
HP printer. This prints values as strings to the serial monitor to see results of the code and
hardware you set up. This is usually a good place to extract information after processing.

10.4 millis()
Perhaps the neatest but trickiest function you have in your toolset. If you’ve ever watched soccer,
basketball, or almost any sport, you’ll notice they all have time keepers. millis() is your time
keeper. What you ask is: How long has my Arduino been running for ? The answer you get: A
value representing how long the Arduino since you first ran your program. Key things to note:
1. Should include a variable to receive anything since millis() returns an int value (Refer to
section 9.2).

18
2. List of parameters is empty
3. WHY ? Because you can do an action at certain time frequency (Every second
print this, or every 5 seconds read this) without using delay() and pausing your
program

11 Processing
What is processing ?
Processing is a flexible software sketchbook and a language for learning how to
code within the context of the visual arts. Since 2001, Processing has promoted
software literacy within the visual arts and visual literacy within technology. There
are tens of thousands of students, artists, designers, researchers, and hobbyists who
use Processing for learning and prototyping. 2
Basically processing helps you visualise data. In our case, it will help us plot our information.
To help explain how processing works I will use a piece of code posted in one of Dr.Don Devoe’s
lab manuals.

Figure 8: Example of Simple Processing Code

11.1 How to send data to processing


Very simple. The minute you use the Serial.println() funciton described in section 10.3 Pro-
cessing can pick it u and manipulate it.

11.2 How to receive this data ?


The following line is responsible for grabbing that data from the serial monitor. It stuff it into
the string variable inString.
String inString = myPort.readStringUntil;
2
According to processing.org

19
11.3 Formatting correctly
Usually what happens is we send 3 or 4 values through Arduino to processing split by a comma
or a tab. How can we extract those values and make them useful to use ? Through the use of
a function called split().
This is used in the example above as follows:
xyRaw = splitTokens(inString, ”,”);
It takes our input of 4 or 5 elements and it splits them into an array data structure. What does
it split them by though ? By the comma.
For example an input of ”3, 4, 5” would be put in an array such that the first element with
index 0 is 3, second element with index 1 is 4, and third element with index 2 is 5.
What if I wanted to split them based on the letter a ? The code would change to the following:
xyRaw = splitTokens(inString, ”a”);

11.4 Plotting
Finally plotting. After we extract out values from the array. We can now use the ellipse function
to plot our numbers on a nice graph. Line of code would look like this:
ellipse(x, y, 3, 3);

12 Addendum
12.1 Surveys
The following are the surveys I have collected regarding the manual.

Figure 9: Coding platforms used by 35 Students before ENME351

20

You might also like