03 Tutorial TinkerCAD Electrical Arduino Tutorial 1
03 Tutorial TinkerCAD Electrical Arduino Tutorial 1
1. Navigate to TinkerCAD.com > Click Sign In Icon (Top Left Side of Screen > Select Students, Join your Classroom >
Classroom CODE: HEQ2VA3WQT4N > Nickname: Student First Name (all lower case)
1. Select Circuits
Arduino has its own IDE Software where the user programs then downloads to the Arduino Board. TinkerCAD offers a
simulation, that allows the user to create a simulated Arduino board and its circuit and then the user can write a
program to receive and/or transmit data to control said circuit.
Arduino uses a C++ based programming language. Arduino Programming Syntax is very similar to C++, so things like
comparison (IF/THEN Statement), Mathematical Computations, Loops (FOR, DO, DO/WHILE), Ending of Line
Statements ( ; ), etc. are written the same. What differs is how to INPUT/OUTPUT data varies.
See Reference Document: Arduino Common Syntax on the class website for common coding commands.
Objective: First Tutorial is designed to simply wire a single LED and then Program its use.
1. Electrical Component Toolbox > Find Arduino Uno > Drag and Drop Arduino Uno onto screen
Digital I/O Pins 0-13: Operate in an On/OFF State. Meaning what is being controlled in these ports is either On or
OFF. Example would be a push button: it is either pressed or it is not, there is no in-between state.
Analog In Pins 0-5: Operate within a range of values, which allows the user to bring in data that is constantly
changing. Example: Thermocouple (Thermometer) is constantly sensing temperature and has a range of values
that it falls into.
3. Wire the following Circuit (Change Electrical Component Ratings and Wire Color as shown)
a. Start Digital Pin 7: The digital pins act as a switch to turn on/off the flow of electricity to the circuit. On the
Arduino Board is a 5V and 3.3V Port that can be used to apply direct electricity to a circuit without
b. Drag Wire to + Row on Breadboard
c. Place Resistor = 220 Ω starting from + row on breadboard to adjacent row
Notice: The end of the Resistor is not touching the Red Wire from Arduino. Once a wire is in either the + or –
row the whole row is charged with electricity
d. Place LED with the pins in different columns. NOTE: Anode (Bent Wire) should be on the Resistor Side and
the Cathode (Straight Wire) should be leading towards the – on the board.
Notice: The end of the Resistor is not touching the end of the LED. Once a wire is placed in the column a-e or
f-j the whole column (vertically) is charged with electricity
e. Drag a wire from Cathode side of the LED to the – Row on breadboard
f. Drag a wire from – row on breadboard to GND (Ground) on the Arduino (NOTE: the Arduino Board has 3
GND (Ground Ports). It does not matter which of these ports the user places the wire.
4. Select the Code Button on the Top Right Hand Side of the Screen > Select Drop Down Menu (Defaults at Blocks) >
Change to Text > Pop-Up Message will appear > Press Continue
NOTE: whenever the users // before any text; the text that follows on that line becomes a comment, which the software will
not read it as a command and skip over it. To comment out large sections at a time use /* at the beginning and */ and the end,
this allows the user to comment large portions of code out at a time.
b. Running the Code. Press Start Simulation > Notice the following
i. Power cord plugs into the Arduino providing electricity to the board
ii. LED turns on for 1000ms or 1s then turns off.
iii. Simulation continues to run until user presses Stop Simulation. Theoretically the program is
continue to run because the void loop() is unbreakable, but since there is nothing located in this
function nothing appears to be happening.
c. Adjust the code as shown below
d. Running the Code. Press Start Simulation > Notice the following
i. Power cord plugs into the Arduino providing electricity to the board
ii. LED turns ON for 1000ms or 1s
iii. LED turns OFF for 2000ms or 2s
iv. Then void loop() repeats itself
- int = integer
- double or float = real number
- char = character
- string = 286 consecutive characters
- among others
One issue we may run into when programming and wiring circuits if we need to move wires for different pins, then in our code
we would have to change the pin numbers more than likely missing one. So, what we will do is use a variable name to act as
our pin.
1. before void setup(): this allows the variable to be used throughout the program (void setup(), void loop(), any other
functions that maybe used
2. in the void setup(): this allows the variable only to be used within the void setup() function
3. above void loop(): this allows the variable to be used by any functions after the declaration
4. in the void loop(): this allows the variable only to be used within he void loop()
Depending on what you want the variable to do will depend on where it is declared; I prefer to option 1 so I only need to look
in one location. Mind you it depends on the program the more complex the program is the more likely variable declartions
will be placed throughout the program.
1. Adjust the code as follows.
Since the pin we are using is the number 7 and the number 7 is an integer we will declare a variable called redled (my
led is the color red) as a integer and assign the value of 7 to it > then adjust our code to where ever the number 7
appears to redled
a. Run the simulation > Notice the program runs the same as previous
Now the code will be adjusted to turn the LED ON/OFF a number of times then give the illusion that the program has ended
Add a delay statement after the FOR Loop of 3000 ms (3s) > Notice know that the light flashes fast then there
is a long delay to reset itself.
Now we will trap the user within a loop that does not do anything to give them the illusion that the program
has ended by using a while loop.
Serial Monitor
This is where Arduino programming varies from C++ programming when dealing with Input/Output.
Option 2: Serial.println (“TYPE INFO TO OUTPUTTED); or Serial.println (Place Variable Name); Both options will
drop the cursor down to the next line
NOTE: There is not a way in Arduino to mix User Text (“HELLO WORLD “) with variables. Each has to be on its own Serial.print
or Serial.println line
NOTE: TinkerCAD Serial Monitor does not clear the previous run. Refresh the Browser and it will clear the last test run
c. Type the following code where the arrows are located
Submission
Place each screenshot in a Word or Google Document and send me a pdf of completed work.