LearnElectronicsWithArduino
UNDER CONSTRUCTION AGAIN 7/30/25
Learning Electronics With Arduino (CLICK sections to jump ahead)
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.
IF You're Really New To This: See some of electronics parts you'll want to know about HERE
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 (zig-zag symbol) connected from pin 13 then through an LED then down to Ground. Soon you will turn pin13 ON (HIGH to 5V) and light up the LED, 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 of PINS (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 KIDSBLOCK . 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 KIDSBLOCK.
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.
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 ARDUINO SKETCHES
LEARNING SOFTWARE AND DATA CONCEPTS AND CODING
The Arduino UNO we are using is usually programmed in the C++ language. A good way to begin programming concepts for students is to use a visual “Drag-and-Drop” system on a desktop/laptop computer. The SCRATCH program developed over years at MIT is a good example, and we will use a version of SCRATCH3 that includes great support for Arduino and ESP32. It is called KIDSBLOCK.
Here is a quick look at KIDSBLOCK where the device that has been selected is the ARDUINO UNO. We use a version that has many extra pins making it easier to use. Below the traditional BLINK program has been made by pulling Blocks out from the left menu. The Arduino has a built-in RED LED on PIN 13 and we will use that first. You can see on the right the C++ text code that has been created from the Arduino and it WORKS!
DIGITAL SENSORS AND DIGITAL ACTUATORS
Now we will go beyond "Digital Binary" devices that are only ON or OFF.
Many complex and useful devices do much more than turn ON or OFF or DIM. One way they can do this is by sending a longer pattern of On and Off, 1s and 0s, that convey information (such as temperature values). This pattern is a called a Digital Signal
Understanding these digital signals is like knowing a foreign language. We use the word "protocol" to describe a digital language. Like a foreign language, you need a translator to understand each digital protocol. But! Don't worry. Lots of people, all over the world, use Arduino, and they have written translators for Arduino to understand all kinds of digital protocols, for all kinds of devices. Just like you can find a foreign language dictionary at your local library, these protocol translators are in libraries too. These are "libraries" of software that the Arduino team or other people have written for us to use, and are already installed into KIDSBLOCK. When we figure out how to do something cool, or how to understand a new digital protocol, we might put our code in a Library and share it with others.
DIGITAL SENSORS
Pushbutton
Let's start with the simplest kind of sensor: a Pushbutton. YOU push the button, it puts out a 1 or a 0 . You connect it to an Arduino Input pin.
We already know how to turn the Pin13 LED on, right?? OK here's a pushbutton wired to the Arduino:
Use a 3-pin cable to connect the switch to Arduino Pin 2. Then start KIDSBLOCK.
Drag out a Set Digital Pin block so you can control the LED
Drag out a Read Digital Pin block so you can see what the Switch is doing.
You need to use the little PullDown buttons to set the PIN NUMBERS you will use.
Hook them together like this:
With Arduino connected by USB, UPLoad that. Try pushing the Button! What happens??
UH-OH The LED is ON before you press the button. And if you press the button the LED goes OFF.. The world is UpsideDown!!
REALITY CHECK TIME Look at our Diagram. Look at the SWITCH, the PULLUP RESISTOR and the INPUT.
What is the INPUT connected to when the switch is NOT pressed?
It's pulled UP to a "1" (Also Known As HIGH AKA +5V) so the LED is turned on. When it's pressed, INPUT is connected to (GROUND AKA "0" AKA "LOW").
Get used to thinking about Arduino DATA as ("1" or "HIGH" or TRUE or "+5V") OR ("0" or "LOW" or FALSE or "GROUND").
IT's EASY TO FIX! LET's DO IT.
Think about this LOGICically. Like what is True or False. In KIDSBLOCK click on OPERATORS on the left. Drag out a "NOT" . Also drag the "Digital Read" off the "Digital Write". Connect the NOT before the Digital Read. Like this:
Then move the Not Digital Read back to the Digital Write.
Now UPload that. How does it work now?? You can always FIX any data that is UpSideDown.
BUZZER
Now that you can make the LED come on when you push the button, let's also make a noise when you push it. Look in the Kit for "Buzzer Beeper". They are small round black parts. See the photo to tell them apart. You want the BUZZER. Note that one connection is marked (+). See INFO HERE
Get the multicolored RIBBON CABLE out of the Kit. INFO HERE NOTE: one side starts with BRown-ReD-ORange. Grab BR and RD close to the end and strip them off together separate from the rest. Now you have a "Cable".
Here you can see the small black BUZZER. Note the (+) pin and push the RD wire from your cable onto it. Push the BR wire on the other pin. Then connect the RD-BR cable connected to Arduino. BR to Pin13 Blue (Ground) and RD to Pin13 Yellow (Signal).
PUSH THE BUTTON
Ultrasonic Distance Sensor
This is a more complex sensor but it's not hard to use. It has a complex chip on it to do most of the work.
Small low-cost ultrasonic distance measurement modules like this: HC-SR04 are an effective way to sense the presence of nearby objects and the distance to them. Often Robots use these to sense objects or collisions and take appropriate action.
Here's how these modules work: They have two transducers, basically a speaker and a microphone. Ultrasound is a high frequency sound (typically 40 KHz is used). A short burst of sound waves (often only 8 cycles) is sent out the "Transmit" transducer (left, above). Then the "Receive" transducer listens for an echo. So, the principle of ultrasonic distance measurement is the same as with Radio-based radar.
Distance is calculated as: L = C × T/2 , where L is the length, C is the speed of sound in air, T is the time difference from the transmission from the transmitter to the receiver. This is divided by 2 for the two-directions the sound travels. Speed of sound is about: C = 344m / s (20 degrees C room temperature). Speed of sound in air velocity is affected by the air density, and for high accuracy the temperature must be taken into account, either within the module electronics (In the SRF-06 module we have) or in the Arduino software.
Understanding the Science Behind the Ultrasonic Distance Sensor
We have a educational page HERE with much more information about Ultrasonics and Echo Location. It includes a link to a slide show suitable for use in the classroom.
Ultrasonic Module Connections
The module in our example has 4 pins:
- Vcc Operating voltage: 5.0V
- Trig the transmit signal pin
- Echo the received echo pin
- Gnd Ground
Now, we will use KIDSBLOCK to write Arduino Software to operate the Ultrasonic Sensor:
Using KIDSBLOCK to "Design" the Sketch
KIDSBLOCK is a visual programming tool used to generate code which is then transferred/uploaded to the Arduino. The following steps are taken to program the Arduino using KIDSBLOCK in order to measure distance with the ultrasonic sensor: and Click on its photo. Then cliack BACK on upper left
- Launch the KIDSBLOCK.exe application and ensure sure your Arduino is connected to the computer.
KIDSBLOCK does not show all the possible devices you can use. You have to look thru them and click on one to bring it into the left Block Menu.
Look at the extreme lower left for this Icon:
Take some time to page thru the different available devices.
Find the Ultrasonic Sensor Click on it Photo. Then click "Back" on the upper left.
Now find the new Block on lower left. Click on Ultrasonic. Drag the only block out to the right. It will look like this:
If you are using pin 2 for button, change Echo Pin to 3.
Now add the serial monitor to be able to view the distance. Click on Serial and drag the serial begin baudrate block onto the canvas. This block initializes the serial monitor and sets the baudrate (which is the speed of serial transmission) to the selected number (e.g. 9600).
In the EVENTs menu drag out When Arduino Begin to the top of the screen. Move the Serial Begin block under it. This will run Once when Arduino starts.
In the Control menu drag out Forever
Leave the Ultrasonic block out by itself at the bottom.
In the Control Menu drag out Wait
In the Serial menu drag out Serial Print Here you will show the result distance. Drag it in Forever after Ultrasonic
Drag the Ultrasonic Block on top of the Serial Print, so it replaces the test there.
Move Wait after Serial Print. It should all look like this:
At the lower right Serial Monitor window you should see a number once a second. Experiment with putting your hand or a book in front of the ultrasonic sensor to change the echos it sees. OK It's Not Pretty but it works. Let's learn how to make it prettier. All we need to do is better control the data being printed on the Serial Monitor.
Things we need to Know:
DETECTING OBJECTS WITH ULTRASOUND
Move some flat object like a book in front of the sensor and move it in and out to see the changing distance.
Different objects will reflect a different amount of the Ultrasonic wave, so results will vary a lot. Here are a few examples:
1 ball-point pen, 200mm
2 Hand, 400mm
3.1mm thick plastic sleeve with a wire, 30mm
4. Vernier caliper, 450mm
5. The body (wearing thick clothes), 400mm
6. Wall, 1200mm
7. 1mm thickness soft cotton: undetectable
8. bamboo toothpick, 40mm
9. Stationary Cat ???
Questions or comments welcome
Regards, Terry King
terry@yourduino.com
DIGITAL ACTUATORS
ServoMotor
UNDER REVISION FOR ARDUINO VERSION MAYBE Done
Many complex and useful devices do much more than turn ON or OFF or DIM. One way they can do this is by sending a longer pattern of ons and offs, 1s and 0s, that convey information (such as temperature values). This pattern is a called a Digital Signal.
Understanding these digital signals is like knowing a foreign language. We use the word "protocol" to describe a digital language. Like a foreign language, you need a translator to understand each digital protocol. But! Don't worry. Lots of people, all over the world, use Arduino, and they have written translators for Arduino to understand all kinds of digital protocols, for all kinds of devices. Just like you can find a foreign language dictionary at your local library, these protocol translators are in libraries too. These are "libraries" of software that the Arduino team or other people have written for us to use, and are already installed into KIDSBLOCK. When we figure out how to do something cool, or how to understand a new digital protocol, we might put our code in a Library and share it with others.
Next we are going to use a library to let the Arduino understand how to talk to a Servo Motor.
(A Signal Output): Standard servos like the one in the Kit are controlled by ON-OFF signal pulses sent to them. They rotate their output shaft to a position you command them to go to. You can connect your servo directly to a 3-pin connector on the RoboRED.
Standard Servo Motors (Servo for short) like the one in the Kit were originally made to steer radio controlled airplanes. They rotate the lever on top to the position that you command. To talk to a Servo, Arduino has to send the right pattern of On and Off, the right protocol. There is a library to translate the position you want to the Servo's protocol so it will understand and work correctly. This gives the Arduino a new kind of Output, that can move things on command. The library that the Arduino needs to talk to the Servo is all ready to go in KIDSBLOCK. In KIDSBLOCK, libraries make a new kind of block, that does this new thing. Let's use the Servo block to control the Servo. For these examples, connect your servo to Pin 9 on the YourDuino 3-pin connector, like this:
In KIDSBLOCK, Fill in the PIN# on the Servo block to tell the block where the Servo is plugged in. Tell the block where to point the Servo by giving it a position in degrees from 0 to 180. Its best not to use the very ends of the Servo range, because the gears can jam. So really, its best to only use from 10 to 170. image: KIDSBLOCKServoSweepReturn.jpg
And this block knows it takes a while for the Servo to move to the new place. So you can tell the block to wait by giving it a Delay (in milliseconds) to make sure the Servo has time to get to the new place before KIDSBLOCK goes to the next block.
CHALLENGE: POT CONTROL OF SERVO
Next, lets take an input we know from before, and use it to control the servo.
With your Pot connected to Analog Pin 0 (First Analog pin) you can make the servo follow your pot position.
Remember: The Pot digital value goes from 0..1023 You will need to map that to the servo 0..180 (degrees)
DC motor controller L9110
UNDER CONSTRUCTION 04/22/2025 -----
Here are the parts we will use to test how this all works. There are a L9100 Motor driver board (2 channels for 2 motors), a yellow DC motor, A Joystick and a ribbon cable we will use to connect things. Separate out a 10wire section from a wider cable, from Brown (1) to Black (0)
On the right is the cable layout we will use. Notice that some unused wires are folded back under. The remaining wires are the right (according to Color Code) Numbers for the Arduino pins they will be connected to.
Here are the connections we will make from motor(s) to Arduino. Ribbon cable to Arduino on left, Motor Wires on right.
KIDSBLOCK EXAMPLE
UNDER REVISION FOR ARDUINO VERSION
Here is a simple example which controls the motor pins 3 and 5. This runs the motor in forward and reverse at at medium speed.
This example shows how to do things that are more complicated but build ability to do many complex things. It creates -----Procedures----- for certain functions.
ARDUINO IDE EXAMPLE
/* YourDuinoStarter Example: Sketch Template
- WHAT IT DOES Tests 1 motor on L9110 motor driver
- SEE the comments after "//" on each line below
- CONNECTIONS:
- L9110: +5v , Gnd, A1A=pin3, A1B=pin5
- Yellow geared motor or Equivalent: L9110 = MotorA
- V1.00 01/30/2025
Questions: terry@yourduino.com */
/*-----( Import needed libraries )-----*/
//none
/*-----( Declare Constants and Pin Numbers )-----*/
// Define L9110 control pins
#define motorIA 3 // Connect to IA on L9110
#define motorIB 5 // Connect to IB on L9110
/*-----( Declare objects )-----*/
//none
/*-----( Declare Variables )-----*/
//none
void setup() /****** SETUP: RUNS ONCE ******/
{
// Set motor control pins as outputs
pinMode(motorIA, OUTPUT);
pinMode(motorIB, OUTPUT);
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
// Rotate motor clockwise
analogWrite(motorIA, 255); // Full speed
digitalWrite(motorIB, LOW);
delay(1000);
// Stop the motor
digitalWrite(motorIA, LOW);
digitalWrite(motorIB, LOW);
delay(2000);
// Rotate motor counterclockwise
digitalWrite(motorIA, LOW);
analogWrite(motorIB, 255); // Full speed
delay(1000);
// Stop the motor
digitalWrite(motorIA, LOW);
digitalWrite(motorIB, LOW);
delay(4000);
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
//none
//*********( THE END )***********
STEPPER MOTORS
ABOUT STEPPER MOTORS:
An excellent page about stepper motors is on the RepRap 3D Printer WIKI here:
A stepper motor is a motor controlled by a number of electromagnets. The center shaft has a series of permanent magnets mounted on it, and the electromagnets surrounding the shaft are alternately given current or not, creating magnetic fields which repulse or attract the magnets on the shaft, causing the motor to rotate.
This design allows for very precise control of the motor: by proper pulsing, it can be turned in very accurate steps of set degree increments (for example, two-degree increments, half-degree increments, etc.). They are used in printers, disk drives, and other devices where precise positioning of the motor is necessary.
Small Stepper Motor and Driver Board
KIDSBLOCK sketch below..
NOTE: The connections can be confusing! The code examples below assume you are connecting 4 Arduino pins in sequence to pins IN1,IN2,IN3,IN4 on the motor driver board shown. Then in the stepper library statement the correct sequence of motor pins is taken care of. See photos below.
Example: Arduino Connections
Pins 8,9,10,11 will be connected to In1,In2,In3,In4 Color code sequence: Brown-Red-Orange-Yellow Then Green=Ground, Blue=5V
It's easier to get the connections right if you use colored wires like THESE
Arduino Pin |
Driver pin |
Color |
8 |
1 |
brown |
9 |
2 |
red |
10 |
3 |
orange |
11 |
4 |
yellow |
GND |
- |
green |
VCC +5V |
+ |
blue |
Then software is initialized in 1-3-2-4 sequence:
Stepper small_stepper(STEPS, 8, 10, 9, 11); //Example Software Sketch below.
NOTE: If your motor just buzzes or runs incorrectly, the connections are probably wrong.
KIDSBLOCK SKETCHES CONTROL STEPPER MOTOR
TO DO: Pot controls stepper speed and direction..
NOTE: The StepsPerRevolution value MUST agree with the physical motor you have. It is 2048 for the small geared stepper we show.
NOTE: The SetSpeed value is in Revolutions Per MINUTE (RPM). These geared-down motors have a MAXimum of 15 RPM.
StepperHalfTurnReverse
UNDER REVISION FOR ARDUINO VERSION
Get the .MIX file here: https://www.yourduino.com/docs/KIDSBLOCKExamples/StepperHalfTurnReverse.mix
StepperOneStepAtATime
UNDER REVISION FOR ARDUINO VERSION
This example steps the motor ONE step at a time, very slowly (You can change the delay). This shows the actual action as the software and the motor driver board do a sequence of four bits ON and OFF in the right sequence of the internal electromagnets to turn the motor. NOTICE that two magnets at a time are always turned on, and also that only one magnet is changed at a time for each step.
Get the .MIX file here: https://www.yourduino.com/docs/KIDSBLOCKExamples/StepperOneStepAtATime.mix
JoystickStepperPosition
UNDER REVISION FOR ARDUINO VERSION
This example reads the position of the X axis of a joystick and calculates how many steps clockwise or counterclockwise are needed to position the stepper. The Joystick position is calculated a 0 to 350 degrees. The stepper starts at the Joystick center position which is defined as 180 degrees. As the joystick is moved towards 0 or toward 360 degrees the stepper follows the motion. If the joystick is released to its center position the stepper goes back to the 180 degree position.
Get the .MIX file here: https://www.yourduino.com/docs/KIDSBLOCKExamples/JoystickToStepperPosition.mix
Here's a look at the way we tried this out...
MOTOR DETAILS
The small stepper motor and driver board in a typical kit is a 5v 28YBJ-48 Stepper Motor with Gear Reduction, so it has good torque for its size, but relatively slow motion. These motors/drivers are made by the millions for A/C units, fans, duct controls etc. which is why they are so inexpensive.
4 Phase 5 Wire Connection
- Phase : 4
- Current : 160 mA per winding (320 mA total in 4-step mode) Measured: 250mA stopped, 200 mA running fast
- Resistance : 31 Ω per coil winding (from Red wire to any coil) (Some 24-28 ohms)
- Voltage : 5V DC
- Step Angle (8-Step sequence: Internal Motor alone): 5.625° (64 steps per revolution)
- Step Angle (4-Step sequence: Internal Motor alone): 11.25° (32 steps per revolution)
- Gear Reduction ratio: 1 / 64 (Not really exact: probably 63.68395.:1 )
- SO: it takes (64*64 = 4096 steps per output shaft revolution.. In 8-step sequence.
- SO: it takes (32*64 = 2048 steps per output shaft revolution.. In 4-step sequence.
- NOTE: Arduino "Stepper Library" runs in 4-step mode
- No-Load Pull-Out Frequency : 800pps
- No-Load Pull-In Frequency : 500pps
- Pull-In Torque : ≥ 78.4mN.m
- Wiring Instruction : A (Blue), B (Pink), C (Yellow), D (Orange), E (Red, Mid-Point)
- Weight : 30g
PROBLEMS?? (Motor Just Vibrates??)
NOTE: If your motor vibrates but does not turn or will only run in one direction, it's wires are probably connected with the wrong sequence.
The Arduino pin connections need to have 4 pins connected to Motor Driver In1, In2, In3, In4 and then the pins entered in the software in the sequence 1-3-2-4 for proper sequencing. Also, The + and - pins near "5-12V" need to be connected:
- - to Arduino Ground,
- + to Arduino +5 (for one motor test only) or (best) to a separate +5V 1A power supply.
ANALOG SENSORS AND ACTUATORS
'NEXT: Use Arduino as a VOLTMETER and learn Voltage Dividers
OK, its time to continue learning about Voltage,Current, Resistance and All That. You will need that to be able to build interesting projects.
If you have a multimeter / Voltmeter device you can use it also. NOTE: Egypt: RAM has THIS:
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 .sb3 file WILL BE HERE SOON
NOTE: To download .sb3 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 (Samples?)
- First connections: +5v , Gnd.
- Measure with Multimeter if available
- Breadboard: Bond top to bottom Voltage and ground rails??
- Example: Resistor and LED To 5V and to Ground.
- THEN KIDSBLOCK and Blink
- Then external Resistor/led
ANALOG SENSORS
Voltage Dividers:
Now let's figure out this Voltage Divider stuff. Look at the diagram above. A Voltage Divider has 2 resistors connected in Series, connected to a source of (V)oltage and a (G)round or common point. The connection in the middle between the two resistors is the (S)ignal Output, and is some fraction of the Input Voltage. So we can connect a pot used as a Voltage Divider into the breadboard and connect it with wires.. As we move the pot, the output voltage going to Yourduino varies from 0 to 5 Volts and all the values in between. The way Arduino works gives values from 0 to 1023.
Here are some different potentiometers:
Some potentiometers have a knob you rotate like a volume control. Some have a straight sliding movement. And there are Joysticks which have two potentiometers which change with the handle position.
Let's look "inside" some potentiometers.
One is a "rotary" type and the other is a "slide" type. In both cases, inside there is a Resistive Strip of some material like carbon. The two ends of the strip connect to (V)oltage and (G)nd. The Wiper is moved along the strip when you move the knob on the pot. So you can change the voltage divider action, and send different voltages out the Wiper to an Arduino Analog Input. Arduino can read and report that Voltage, and tell where you moved the knob to. So your human movement becomes a value known to Arduino.
For a LOT more about "Pots", see "The Secret Life of Pots" by R.G. Keen HERE
Analog: Potentiometer sets blink/beep delay
UNDER REVISION FOR ARDUINO VERSION
Here is a Potentiometer on a breadboard we used for this example:
This example reads the value of a Potentiometer (like a volume control) and displays the value on the Serial Monitor. It also sets the delay in blinking the Pin13 LED.
Here's a KIDSBLOCK sketch that does that.
Analog SENSORS that change their resistance
If we have a photoresistor (Light-dependent Resistor) connected in series with a resistor, we have a voltage divider that changes with the light intensity, giving us a varying voltage. If we have a Thermistor (Temperature-dependent resistor) we have a voltage divider that changes with temperature.
What if you want to measure voltages that are more than 5 volts? You use a Voltage Divider to reduce the voltage. If you make a 3 to 1 ratio voltage divider (say, 20K for the top section and 10K for the bottom), then you can read voltages from 0 to 15 volts. Good for automotive batteries. You could to this by putting two of your 10K resistors in series for the top resistor.
Photo (light) Sensor Brick
This is a sensor that reacts to the light level by changing it's resistance. Often called a PhotoResistor. Here's what one looks like on a small circuit board with 3-pin connector.
Here's a KIDSBLOCK sketch that reads the value from the PhotoResistor with an Arduino Analog Input. The value is displayed on the Serial Monitor. The light level is compared to a (changeable) threshold light level and if it is now darker than the threshold the Pin13 LED is turned on. You could use this to operate a relay to turn on lights, as an example.
Richt-Click and "SaveAs" to download the .Mix file. PhotoresistorValues-LED-OnDark.mix
Several Useful Voltage Dividers
Here are several ways "Voltage Dividers" are used with Arduino: (Better Graphic Coming!!)
Those examples (one at a time!) are:
(A) equal voltage divider. The voltage is Half of applied voltage. We use +5V so that mid point will be 2.50 V
(B) three equal resistors. Voltages are 1/3 5V and 2/3 5V
(C) Potentiometer: continuously variable voltage output 0..5V
(D) Same as A but a light dependent resistor AKA Photocell is the top resistor. In dark, voltage out is almost zero. In sunlight it would be almost 5V . So: Increasing voltage out with increasing light. In KIDSBLOCK, the value could be compared to a constant and then action could be alarm etc.
(E) Same as A but top resistor is temperature dependent "Thermistor". Lower resistance with higher temperature.
The Light Dependent resistor and the thermistor are both rated as 10K ohms at a standard condition. Its 25C for the Thermistor. I forget the standard for the light.
Using a Multimeter to measure voltages (Optional: can go directly to Arduino/KIDSBLOCK 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
JOYSTICK = 2 Potentiometers and 1 Switch
Now that we see how potentiometers act as voltage dividers, let's look at the Joystick which is really two potentiometers connected to a handle.
A ROBOT EXAMPLE: MotorDriver/Ultrasonic/Servo
UNDER REVISION FOR ARDUINO VERSION
Let's talk about Integrating what we've learned to make a small "Robot Car".
This robot will include the main parts we have already learned about:
- The Ultrasonic Distance Sensor
- The ServoMotor (To point the Ultrasonic in multiple directions
- The Motor Driver to separately control the Yellow DC motors and wheels
TO DO: WIRING DIAGRAM
You will see the fairly complex KIDSBLOCK code below that moves the robot forward, and then "Looks" (with ultrasonic echo sensor) Left, Right And Ahead for obstacles. The it moves away from the obstacle and resumes running.. But in KIDSBLOCK you can write named procedures that do specific things, like "Turn Left 90 degrees", and test them. Then in the main loop you use those names, so it looks like this:
Get the .MIX file here: https://www.yourduino.com/docs/KIDSBLOCKExamples/LookAroundTry4.mix
CONTROLLING HIGHER POWER
Power FET brick
This module can switch DC power (5V to 24V DC) on and off. Current switched can be up to 3 to 5 amps.
Pinout and Connections
Pin/Terminal Function -------------- -------------------------------------------- SIG Control signal (from microcontroller) VCC 5V logic supply GND Ground (logic and load reference) VIN Input voltage for the load (5–24V typical) V+ Positive terminal for the load V- Negative terminal for the load
- The **SIG** pin receives the control signal (PWM or digital HIGH/LOW) from the microcontroller.
- **VCC** and **GND** are connected to the 5V and GND pins of the microcontroller, respectively.
- **VIN** and **GND** (on the screw terminals) are connected to the external power supply for the load.
- The load is connected to **V+** and **V-** (or OUT), which are switched by the MOSFET
Typical Use Cases
- Switching DC loads such as motors, LEDs, pumps, or solenoid valves.
- PWM control for dimming LEDs or adjusting motor speed.
- Allows microcontrollers to safely control higher voltage/current devices.
POWER FET Example: Dimming 12V bulb
We will use the PowerFET module to control and dim a 12V 2 Amp bulb of the MR16 type often used for home lighting. NOTE: We are using an Incandescent version. Newer MR16 LED bulbs are not dimmable but can be switched ON and OFF with the PowerFET module.
Review the PowerFET module connections above. Since we want to use PWM to dim the bulb we must use an arduino pin that supports PWM. We'll use pin 11.
So there are 3 hardware connections we need to make:
- the signal from arduino pin 11 to the PowerFET module: 3 wires or a 3-pin cable with these connections
- GND Ground
- VCC Voltage (+5V)
- SIG Signal
- EXTERNAL Power for the bulb. We will use a 12V 2 amp rated plug-in power supply.
- GND (The Negative connection of the external supply)
- VIN (+12V IN - The positive connection of the external supply)
- The LOAD (The bulb in this case)
- V- (Voltage Minus to the bulb. Incandescent does not matter, but LED bulbs must have correct polarity.
- V+ (Voltage Plus to the bulb)
CONNECTION view
- Notice the 3-pin cable to Arduino pin 11 (and Gnd and +5V Vcc)
- See the POWER connection on the lower right of the module
- See the LOAD (bulb) connection on the lower right of the module
UNDER REVISION FOR ARDUINO VERSION
KIDSBLOCK Example: PWM controlling the bulb Brighter and Dimmer
Note that the PWM values go from 0 to 255 and back to 0
The Arduino C++ Code generated by KIDSBLOCK, for example
See the C++ mode that KIDSBLOCK generated to actually program arduino to control the bulb
VIDEO of the bulb being controlled (click the photo) =
Relay boards
Here is a typical relay board with two identical relays. A Relay is a SWITCH that is flipped by a small electromagnet inside the case of the relay.
How Relay Contacts Work:
Look at the photo of a relay on the left. Notice the 3 screw-type terminals. They are labelled "NO", "COM", "NC". Those labels mean:
- NO: Normally Open
- COM: Common Connection
- NC: Normally Closed
Look at the diagram on the right. This shows the switch that is inside the relay. This switch is "thrown" by the electromagnet inside. The diagram shows that COM is connected to the Normally Closed contact. That's the case when the relay is off. When the relay is turned on the electromagnet flips the switch up and COM is then connected to Normally Open. So, if we want a lamp to be on when the relay is on, we connect our circuit from COM to NO.
Relay Board How-To and Examples
Optical Isolation
"Optically Isolated" means an "Opto-isolator" chip is used to isolate the relay from the Arduino. See: http://en.wikipedia.org/wiki/Optoisolator So only a beam of Infrared light (The little blue arrows in the diagram below) connects the Arduino circuitry to the relay and switching parts. Here's what an opto-isolated board looks like, followed by it's circuit diagram:
Optoisolation / Crydoms
COMMUNICATIONS SYSTEMS
- wired systems
- wireless systems: Bluetooth and WiFi