Starting from:

$30

CS341-Lab 1 Virtual Arduino Solved

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

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.

2.    Make the connections (pin 13 - b2) and (b1 - GND)

3.    Grab a led from the components and connect it to j1 and j2

4.    Connect a resistor to d2 and f2

5.    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.

3.    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().

 

4.    Click “Start Simulation” and your LED should blink

5.    Now add the two following lines to setup():

Serial.begin(9600); 

Serial.print("Hello, World!"); 

6.    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.

More products