LearnElectronicsWithArduino
UNDER CONSTRUCTION 3/3/25
Learning Electronics With Arduino
What IS "Electronics" ??
Electronics is a scientific and engineering discipline that studies and applies the principles of physics to design, create, and operate electrical devices like Cellphones, Computers, Vehicle controls, Robots etc. See: (WIKIPEDIA) It's much more than just switching some power on and off.
IF You're Really New To This: See some of the Jargon you'll want to know HERE
Electricity Basics
There are a couple of little problems:
NO WORRIES! We will show you the ways to make these powerful tools Visible so you can use them.
ELECTRICITY WORDS
These 3 words are the basic things you'll learn about here. Right now they're just words but you will touch them soon!
VOLTAGE is the electrical pressure or force that drives current through a circuit. It's measured in volts (V) and represents the potential energy difference between two points in a circuit. EXAMPLES:
- 1.5V DC AA battery
- 3.7V DC Lithium Battery
- 12V DC Car battery
- 120V AC - USA usual outlet
- 220V AC - England, France, Egypt etc. usual outlet
- 380V AC - 3-phase line to line voltage (220V times the square root of 3 - Why?)
CURRENT is the flow of electric charge through a circuit. It's measured in amperes (A) or amps and indicates how many electrons are moving through the circuit Each Second. EXAMPLES:
- 0.02 A LED (Light emitting Diode)
- 6.0 A Automobile headlamp
- 0.5 A USA 60 watt old type light bulb
- 0.05 A USA LED Light Bulb (Same light as old type bulb)
- 4.0 A Automobile windshield wiper motor
- 350 A Automobile engine starter motor
RESISTANCE opposes the flow of current in a circuit. It's measured in ohms (Ω) and depends on factors like the material, length, and cross-sectional area of the conductor. IF we know Voltage and Current in a circuit we can find resistance by dividing Voltage by Current: R=V/I EXAMPLES:
- Automobile Headlamp: R=V/I R= 12/6 = 2 Ohms resistance
- Old type 120V 60W bulb : R=V/I R=120/0.5 = 240 Ohms resistance
- Automobile windshield wiper motor R=V/I R=12/4 = 3.0 Ohms resistance
When you start connecting real devices like lights and motors, sometimes you will need to figure this kind of stuff.
CIRCUITS
You probably know that electricity only flows when there is a path or circuit from a source of electricity through some load (like an LED) and back to the source
We will now start using Arduino to try out these ideas and get to understand them.
Learning by using Arduino
ARDUINO is a small $15 computer that you can use to make many interesting projects. It is easy to connect things to like SENSORS (for temperature, light, pressure etc etc.) and ACTUATORS (like LED lights, motors, displays, valves etc etc.) You will program it to run the things you design.
The YourDuino RoboRED is used in your kit. (You may have an almost-identical version that is Black) It is equivalent to an Arduino UNO but has several added features, like easy-to-connect pins on every Input/Output pin. Near the upper left is the PWR LED which should light up whenever the board is plugged into a USB connection, or has power from an external power supply.
At the upper left there are two added red LEDs which will blink when a software sketch is being downloaded to the board, or other data is being transferred over USB.
In the center is a red LED which is internally connected to pin 13 through a current-limiting resistor. It should blink after you load the example BLINK software sketch. The colored 3-pin connectors on every I/O Pin make it easy to connect many input and output devices. Vcc(+5V) pins and (Ground) pins with every I/O pin are good for connections to breadboards etc.
Using Arduino to understand Electronics
If we understand this stuff, we can start to make many more-interesting things work. Let's THINK about it. We have wires and circuits and electricity. It's easier to think about it if we use some SYMBOLS to make DIAGRAMS. Let's look at This Diagram :
Slow Down Time: Look carefully:
Your RoboRED (Arduino) runs on Electricity. A supply of '5 volts' comes from the USB cable or batteries. At the top and bottom of the diagram there are two main connections:
5 VOLTS
GROUND
Find them on the diagram. What about "RAILS"? A lot of things connect to that 5 Volts and that Ground. Tekkie-Speak calls them 'rails' like railroad rails running through a project or circuit. Some call them "BUSSES" like "The 5 Volt BUS" More Jargon!
NOTICE: On the diagram, there is a Resistor connected to an LED from pin 13 down to Ground. Soon you will turn pin13 ON (HIGH to 5V) and light it up, and you will turn pin13 OFF (LOW to Ground) so you can make it blink.
Now take a CLOSE LOOK here at the actual Arduino. This detail shows the ROWS of PINS on your arduino: Look for the RED (5 Volts, remember??) look for the BLUE (Ground) and note there is also a YELLOW row (Where you will connect may other things like Sensors and Actuators. Now look at YOUR actual arduino. See those rows of pins and their color?? OK!
What is Physical Computing ?
Using a computer to SENSE real things like temperature or light or pushbuttons and using the computer to CONTROL real things like lights and motors is called PHYSICAL COMPUTING.
- One way to do this is to write code using the Arduino IDE system and upload it directly to an Arduino. This code is written in an easy version of C and C++ that is specific to Arduino.
- A second way is to write your code in a Block Oriented visual Drag and Drop system called MIXLY . We will show you how.
And you will need HARDWARE . You will start with a "KIT" which is a box (Photo Below) that includes an Arduino Microcomputer, cables, and a selection of sensors and actuators, LCD display etc. so you can get right into connecting your Arduino, connecting devices and trying out simple Software Sketches with MIXLY.
SO.. What IS ALL THIS STUFF??
Kit Contents LISTS
Here is the list of all the parts in the kits from Yourduino. For some schools parts were added to the standard kit. They are marked "ADD" on the left side. The kits are like the large photo above PLUS those "ADD" parts.
Media:KitNumbersOriginal-Added.pdf
HOW Do These Things Work TOGETHER ? ?
Here is how we will THINK about Arduino. There are three main things that are part of all automatic systems:
[Sensor Inputs | Software Decisions | Action Outputs]
All automatic systems, from a simple thermostat to the Mars Rover have those 3 parts.
When you create a new project, YOU will decide the three things:
- WHAT Sensors and Inputs you will CONNECT to Arduino, and on What Pins
- WHAT Software Decisions you will make as you write CODE
- WHAT Output Action Devices will you connect to Arduino, and on What Pins
Sensor Inputs:
These can be simple like a pushbutton switch or complex like a GPS receiver or an accelerometer. There are hundreds of possibilities for sensing things in the Physical World.<br
Action Outputs:
These can be simple like an LED or complex like the motors and motion control of a Robot.
Software Decisions:
This is where you decide what Sensor Inputs Arduino will look at, what Decisions it will make , and what Action Outputs it will cause to happen. You will decide how your project Behaves by how you make decisions in software. You make this actually work by writing software code statements. The software should be organized so these 3 things happen over and over again in Loop:
- READ SENSORS
- MAKE DECISIONS
- TAKE ACTIONS
There are two different types of Inputs and Outputs and you need to understand the difference:
DIGITAL INPUTS and OUTPUTS
'DIGITAL things are BITS that have only two possible values: 0 or 1. Like "The light is OFF or ON"
ANALOG INPUTS and OUTPUTS
'ANALOG things are VALUES that have a Range of Values. Like "The light is BRIGHTER or DIMMER or in between.
The STRUCTURE of an ARDUINO SYSTEM
Let's take a look at this diagram that shows the structure or "architecture" of a microcomputer based system like Arduino.
This shows examples of the kinds of Digital Input devices you might use. And Digital Output devices.
It also shows examples of Analog Input devices and 'Analog Output devices.
AND it shows examples of devices that communicate with SIGNALS that are a sequence of Digital Ones and Zeros. They communicate Data with those signals.
OK, now You go ahead and control A Digital Output (an LED) with software you write.
SOFTWARE TIME - CREATING MIXLY SKETCHES
Start the MIXLY software on your computer. Let's take a little while to get used to creating MIXLY sketches by dragging functions out from the library on the left. Then we'll come back and start connecting your GIS-MakerSpaceElectronicsCourse kit parts and making more interesting things. We will give you MIXLY examples for each of the devices in the kit.
LOOK AT THE MIXLY MAIN SCREEN
Slow Down! Look at all the parts of the screen. Soon you'll be used to it and get a lot of stuff done.
- The LEFT SECTION: "BLOCKS" has many things you can pull out onto the main screen. The example shows 4 blocks that have been pulled out, and clicked together.
- The CENTER SECTION is where you place your blocks. You also type in or select choices or numbers in the blocks
- UPPER RIGHT selects Language. It may start in Chinese and you'll have to set it to your language
Here is another view of the MIXLY screen. We will use these marked things later:
- BOTTOM CENTER: (Red marked) Things you MUST set up to have things work.
- FIRST, YOU MUST SET THE CORRECT BOARD TYPE AND SERIAL PORT
- "Arduino/Genuino UNO" is correct for us
- The entry "COM3" in the example will be different. On the PC There will usually be only one choice. But you may have COM1 and then some higher number which is Arduino.
- On the MAC, pick the entry that has "tty" in it.
- BOTTOM CENTER also has two buttons:
- "Compile" Checks all the BLOCKS you set up in your code. It might cause error messages that would be found in the LOWER SCREEN SECTION
- You will see a LOT of lines roll by in the LOWER SCREEN SECTION. LOTS of Tekkie stuff you fortunately don't need to worry about!
- "Upload" does both "Compile" and if no errors it creates your Arduino code and UPLOADS it into the RoboRED board, and makes it run.
- "Compile" Checks all the BLOCKS you set up in your code. It might cause error messages that would be found in the LOWER SCREEN SECTION
- FIRST, YOU MUST SET THE CORRECT BOARD TYPE AND SERIAL PORT
After UPLOAD your actual code will start running in the RoboRED or UNO board! In the example, the Pin 13 LED will go HIGH for one second, Then LOW for 1 second. This is called "BLINK!" Next, we'll show you how to DO that!
YOUR FIRST MIXLY ARDUINO SKETCH:
The visible-to-You part of an Arduino software program is called a SKETCH. But the Sketch becomes alive when you upload it to your Arduino. Let's walk through Editing a MIXLY Sketch and Verifying it and Uploading it:
OK, Looking at YOUR MIXLY screen: In the BLOCKS section, click IN/OUT. Should see:
NEXT: Click on the "DigitalWrite" block, HOLD and DRAG it to the right out onto your screen. Should see:
THAT is the way you will find and drag out MIXLY Blocks to use them in your sketches!
BREAK: MIXLY MESS AROUND
Let's get back to your own Software!
Mess around with clicking on BLOCKS sections, and dragging stuff out.
How do you get RID of a block you pulled out? GRAB it with your MOUSE and THROW IT OVER YOUR LEFT SHOULDER! OR click "NEW" in the center tool bar. And there is a TRASH CAN on the lower right too.
FIRST REAL MIXLY SKETCH
NOW: Let's try to do something real. Clear the screen with "NEW" and drag out a "DigitalWrite" block.
NOTICE that there are two SETTINGS you can change: PIN# and Stat. Click PIN# and set it to 13. Leave Stat as HIGH.
DUPLICATE the Block; RIGHT-CLICK and pick DUPLICATE. Drag that block down to make some room. (NOTE: The best place to grab a block is on the little bump on its lower left). On the bottom block change HIGH to LOW.Like this:
NOW get a different block:Click on Control and find and drag out a DELAY block.
Make sure it's separate.Then Duplicate it.
Finally, drag the blocks until they 'click' together like this:
Now LET'S TRY IT OUT!
In the center tool bar, click "Compile". WAIT.. The first time you do this it will take a long time. LOTS of TekkieStuff rolling by in the bottom window. Should eventually say "Compile success!".. Later this will take less than 30 seconds.
HARDWARE TIME!
Get your RoboRED or other Arduino and it's USB Cable. Plug them in. At least one LED should light up on the board. It MIGHT blink another LED.
Before you plug in an Arduino the center bar will look like this: When you plug in, it should show a number like "COM3" or similar. If there are more than one, pick the highest number. Should look like this:
WHAT ARE WE REALLY DOING, HERE?? We are making a computer (The RoboRED or Arduino UNO or other) DO what we TELL it to do.
Later you will be hooking up many other parts, like LEDs and Servomotors and controlling them. For now, we will start by using one LED that is already connected on the Arduino board.
The PIN 13 LED: Every Arduino has one LED permanently connected to PIN 13, and we will use that to get started. And soon we will talk about PINS, BITS, VOLTAGE, HIGH, LOW and ALL THAT.
OK,DO IT! Click on Upload. Watch the stuff roll by as it does Compile, and THEN you should see "Upload Success!"
AND the LED on your Arduino board should blink ON 1 second, OFF 1 second..
WHAT'S REALLY HAPPENING??
Your sketch controls that LED with the "DigitalWrite" block.
and THIS turns it off:
The SKETCH you created DID things. Check it out. Look at the 4 blocks and what they do:
- Turn Pin 13 LED ON (HIGH)
- Delay 1000 Milliseconds (1000/1000ths of a second = 1 second) WATCH the LED being ON
- Turn Pin 13 LED OFF (LOW)
- Delay 1000 Milliseconds (1000/1000ths of a second = 1 second) WATCH the LED being OFF
And LOOP (Do that over and over forever, or until you turn it all off).
OK. Mess with it and see what happens: Change the first "Delay" to 100. Upload. Do you see a short blink??
Change it to 10, then 1 and Upload (Cover the LED with your hand to shade it). Can you see 1/1000 of a second blink?? If you had a BRIGHT LED you could make a strobe light. We'll try some other things in a minute.
END OF COMPLETED (SORT OF) SECTION 2/5/25 (OUTLINE below)
MAYBE NEXT: Use Arduino as a VOLTMETER
OK, its time to continue learning about Voltage,Current, Resistance and All That. You will need that to be able to build interesting projects.
You need a VOLTMETER so you can actually sample the invisible Voltage at different parts of circuits. Soon you will be writing your own sketches but here's a sketch you can use to make Arduino into a 2-channel Voltmeter:
Here's what it looks like: There are Two Analog inputs that can read a range of voltages. One is connected to +5V and the other is connected to the center of a two-resistor Voltage Divider. (You'll hear more about Those!).
Here is a pre-written Arduino Sketch that we will use:
The .MIX file is HERE
NOTE: To download .mix files, RIGHT click and "Save Link As"
CONNECTING to Arduino
OK. let's CONNECT some stuff with WIRES, so we can really understand what is going on.
We will use things like this from the Kit to get started:
- BREADBOARD A prototyping tool used to build temporary circuits without soldering
- diagrams
- First connections: +5v , Gnd.
- measure w MM
- Bond top to bottom
- Example: Resistor and LED To 5V and to Ground.
- THEN Mixly and Blink
- Then external Resistor/led
BEGINNING TO CODE WITH Mixly
OK JargonTime
VERY CLOSE LOOK AT ARDUINO
- RED BLUE YELLOW
- 5V 3.3V
- DIGITAL in/out
- ANALOG in (Analog out)
ANALOG SENSORS
- Two resistor voltage divider..
- Read voltages with Arduino.. Mixly code. Numerical Reality
- Replace top resistor with LDR
- Comparator / alarm / light
- Replace top resistor with Thermistor
- Connect a Potentiometer from +5V to Ground and its third connection to A0
Using a Multimeter to measure voltages (Optional: can go directly to Arduino/Mixly reading voltages)
Get a multimeter and use it to see if we understand this Voltage Stuff. Strip two separate wires off the Rainbow cable. BR (Brown) and RD (Red) would be good. Cut off the connectors at one end. STRIP about 1 to 2 inches of insulation off the cut end. Wind the RD wire tightly around the Positive (+) lead from the multimeter. Use some tape (like used on paper) around it to make it stay in place. Do the same for the BR or other wire.
Connect your actual Arduino with a USB cable to your computer. One red LED should light up. Another LED might be blinking. Learn how to set the multimeter to read "DC Voltage". Then connect the minus (-) lead (BR or whatever you used) to ANY of the pins in a BL (Blue) row. Connect the plus (+) lead (RD or whatever you used) to ANY pin in the RD (Red) row.
What does the meter read?? SHOULD be close to but not exactly 5.0 V. Connect the (+) lead to any of the Ground,(Blue) pins. It should read almost 0.0V
SIGNALS: Digital Patterns have a meaning or data
DIGITAL SENSORS
Bi-directional Data: DS18B20 Temperature sensor DHT11?
DIGITAL ACTUATORS
- servo
- DC motor controller
- Stepper motor controller
CONTROLLING HIGHER POWER
- Power FET brick
- Relay boards
- Optoisolation / Crydoms
COMMUNICATIONS SYSTEMS
- wired systems
- wireless systems: Bluetooth and WiFi