Objective: Program an Arduino on Tinkercad using the language Scratch.
To turn in: I will view your Arduino/Scratch code through the Tinkercad website.
Grading: This assignments counts for 10 points of extra credit toward your homework grade.
Filename Example: fischerAl_tinkercadBlink.png
The user of an Arduino must program it to tell it what to do. Arduino programs are called sketches and are written in C, likely the most common computer language in the world. These sketches are usually composed in a software package called an integrated development environment (IDE).
You’ll gain experience using the Arduino IDE in class. This first exercise will introduce you to programming through an online development environment called Tinkercad. This environment lets you build circuits and program Arduinos virtually through an online interface. Tinkercad incorporates the programming language Scratch, which is a graphical programming language that allows the user to build a computer program using a drag and drop utility rather than a computer command line interface. This is often more approachable for many first-time programmers than the text-based C language.
In Scratch, code is composed of nesting blocks and ovals, where each block represents a function that the Arduino can perform and each oval represents a variable to which the Arduino can save values. The functions are labeled as to what they do in Scratch, while the variables are named by the user.
In this exercise, you’ll build a virtual Arduino with an LED attached. When you’re done with this exercise, you’ll can transfer your code to a real Arduino (Teensy) board in lab.
After logging into the class, go to https://www.tinkercad.com/things/fLDK0dntile-chem-191-exercise-1 and click the Copy and Tinker button. The circuit used for this assignment will automatically be copied to your personal dashboard and your code will be visible to your instructor.
The notes on the circuit can be expanded and will explain what each part is.
Click the Code button at the top right of the Tinkercad window. The code pane will slide out. (See Figure 1, below.)
In the pane that slides out, click the Blocks dropdown and select Blocks + Text. This will allow you to see both the Scratch code and the Arduino code (which is generated by the Scratch code automatically). See Figure 2 for more clarification.
Click on the blue Output circle at the top left of the Scratch Functions area and find the module that says set pin __ to __
. Drag that block into the Scratch Code area.
In the new code module, set the pin to 13
(pin 13 is one of the pins the LED is attached to) and have the code set the pin to HIGH
.
HIGH
means “on” andLOW
means “off” in Arduino speak.
Click on the yellow Control circle at the top of the Scratch Functions area and find the module that says wait 1 secs
. Drag that block into the Scratch Code area.
Put in 1
and select secs
. This will make the code pause for 1 second after the light turns on.
Turn the light off by clicking on Output at the top of the Scratch Functions area, finding the module that says set pin __ to __
, dragging it block into the Scratch Code area, and selecting 13
and LOW
.
Notice how the Arduino code changes as you change the Scratch code!
I will consider two items when grading this: (1) a screenshot of your code submitted to Dropbox (should look like Figure 2, above but with different code) and (2) your circuit on Tinkercad.
There is nothing else you need to do to turn in your circuit. As long as you submitted your completed your circuit within the class area on Tinkercad I will be able to view it.