CS341 Lab1-Virtual Arduino Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (1 vote)

The goal in this lab will be get familiar with a program that mimics an Arduino Uno.

Making an Account and getting started

The website we will be using is https://www.tinkercad.com. There is the functionality to have a class on tinkercad, but we won’t be using that feature this semester.

  1. Click “join now” and create a personal account (this is free)
  2. Click the logo in the top left corner to get to your main page
  3. Click “Circuits” and then “create new Circuit”
  4. Here you’ll see the Arduino simulator

Creating your first circuit

In this lab we will do a simple circuit to get you familiar with Arduino. We will blink a led and say “hello world!”

  1. Use the components window on the far right to get a breadboard and an Arduino Uno. Drag and drop into the middle of the screen

 

The breadboard will be used for connecting wires. It is less useful when wiring digitally and in the future you may decide to wire components directly together. However, for lab 1 I am requiring you to use the breadboard in case you ever need to use one in real life.

If you move your mouse around the breadboard you will see holes light up green. This is to show what holes are connected underneath the breadboard. For instance, 12a through 12e are all connected to one another.

  1. Make the connections (pin 13 -> b2) and (b1 -> GND)
  2. Grab a led from the components and connect it to j1 and j2
  3. Connect a resistor to d2 and f2
  4. Lastly finish the circuit by connecting (e1 -> f1)

Coding in Arduino

Now we need to write some code. First, we need to tell the Arduino to blink pin 13 (which our led is connected to). Second, we need to print “hello world”.

  1. Click the “code” button in the top right
  2. Switch from “blocks” to “text”

Side Note: do not use blocks coding as it is meant for middle-school children.

  1. You should see the default code:

 

First, you may notice that the notation looks familiar. Arduino is technically its own language, but it is a part of the C and C++ family. One distinct difference is the use of setup() and loop(). Setup() will be ran once at the beginning of execution, and loop() will run continuously after setup().

 

  1. Click “Start Simulation” and your LED should blink
  2. Now add the two following lines to setup():

Serial.begin(9600);

Serial.print(“Hello, World!”);

  1. Rerun the code and click “Serial Monitor” at the bottom right of your screen

Some Extra Things to Explore

  1. Try to change how long the led blinks for.
  2. Try changing the amount of resistance on the resistor. What happens?
  3. Try rotating the led 180 degrees. You can do this by clicking on it and clicking the rotate button in the top left corner. Now the longer lead (anode) should be in j1, and the shorter lead (cathode) should be in j2.
  • Lab-1-syj58c.zip