Bus Strip – running length of blue (negative/ground), red (positive) and then to the other side, running length of blue (negative/ground) and red (positive).
Terminal strip – rows a thru e and f thru j – each strip being five holes connected together
Ravine – means of separating the board in two
LED (Light emitting Diode):
-Only allows current to flow in one direction. Di = two and ode = path.
-Long pin on LED is the anode and is positive
-Other (shorter pin) on LED is the cathode and is negative
Resistor:
-Need to reduce/resist the current passing through, for example, an LED
-The resist the flow of electric current
-Ohms – unit of measurement. The higher the Ohm value, the more the resistance
220 Ohm Resistor:
Variables:
-Can be of different types (Integer, Character, Float)
-Integer (int) – can store whole numbers (eg 1, 5, -42, 0)
-Example of an integer variable – int myVariable = 10
Comments (collapsing):
-Theoretically, I should be able to click to the right of line number, and before first character of comment and a collapse symbol shows – it doesn’t
Include Headers:
-This allows us to include code that has already been programmed, into our code
include “Arduino.h”
Defining variables with DEFINE:
define CABIN_LIGHTS_PIN 12
In this case, we defined a variable CABIN_LIGHTS_PIN to be 12. This variable is not going to change
Pin Mode:
-On HERO board, we can have the pins used for input or output. We define using pinmode
-We enter this within the SETUP function
void setup() { pinMode(CABIN_LIGHTS_PIN, OUTPUT);
Loop function:
void loop() { digitalWrite(CABIN_LIGHTS_PIN, HIGH); // This line turns the lander’s light ON. delay(1000); // Wait for one second (1000 milliseconds) with the light ON. digitalWrite(CABIN_LIGHTS_PIN, LOW); // This line turns the lander’s light OFF. delay(100); // Wait for a tenth of a second (100 milliseconds) with the light OFF. }
Connecting HERO Board to breadboard, including placing resistor and LED:
Up to now, my primary experience has been programming. It’s time to take a leap into electronics with circuit building. What will be interesting is integrating the Arduino board with C++ programming. Within the inventr.io 30 Days Lost in Space, Day 2 lesson introduces many new concepts. The component names are familiar, but I’ve never had to understand the details.
This post introduces each electronic component needed for first project (lighting up LED light on breadboard). The next post will be specifics to make the LED steadily light up. Post after that will be integration of programming, where we get LED to blink.
A USB cable connects (and delivers power) from computer to Arduino board. 5 volts of power can transfer from Arduino board to breadboard. Until now, my knowledge is limited to small batteries – 1.5 volts and 9 volts.
Terms used in measuring electricity
Current: Directional flow of electricity in the circuit
Voltage: Commonly 5V or 3.3V (on board). USB is 5V and barreljack is 9 to 12 volts
Analogy of water in a pipe: Pipe = wires; Water = electricity. Voltage is electrical pressure, which will get water out of the pipes. 3.3 volts are lower electrical pressure than 5 volts.
The A/C wall socket outputs 110 volts
Batteries have different voltages: 1.5; 9; 12
Tip: Always check components to ensure can be connected to 3.3 volts or 5 volts. An overvoltage can cause damage to components. An undervoltage can cause component to not run as intended
Amps (Ampere): Measures electric current. For example, how much water can I collect in a bucket in one second. The higher the ampere, in a charger, the more quickly it will likely to charge.
Note: Arduino board can only supply 40mA or 0.04A per pin
Components with higher current draw, or Amps, should be connected to an external power source (eg battery or power adapter).
Watts (wattage – a unit of power):
In our circuit, electricity converted to energy.
Energy / Power = Watts (W)
Formula is: P (Watts) = I (Amperes) times V (Volts)
Water formula is: P (Force of water hitting you) = I (Amount of water in 1 second) times V (Water Pressure)
Summary: Voltage (V) is electric current pressure. Amperes (I) is amount of electricity produced by the current per second. Wattage (P) is how strong is the power produced by current.
Volts:
Flow (direction) of power:
I have basic understanding to know, when inserting batteries, you match the positive (+) and negative (-) ends. It’s good practice to remove batteries from devices if not using for a while – it can corrode.
Breadboard
Rectangular plastic block, under-laid with metal strips, strategically mapped out with holes, allowing for rapid circuit building (ideally from a schematic). Has some limitations, but you don’t need to solder. Orientation of breadboard in my setup is portrait mode, positioned to the right of the Arduino HERO, and both attached to underlying plexi-board.
The following image shows a breadboard, in portrait orientation, that came with the inventr.io kit.
Power lines/rails are the vertical red and blue lines shown on left and ride side of breadboard. Red denotes positive charge and blue denotes negative/ground. Grouping of 5 holes – why. Power runs the length of the power line. Left and right power rails can be connected with jumper wires. Attaching a wire from Arduino 5 volt port, into any hole, would power the entire rail.
Terminal strips are the horizontal rows (aka components lines), for example: row 1, from column a to e. They are all grouped into 5 holes (named A – G and F – J). Columns of the group are marked with numbers.
Down the middle is just plastic, but it’s relevant, as I’ve seen components that have pins straddling left and right side of the board. You may have a component with a DIP (Dual Inline Package) – one set of pins will straddle each side. It also prevents IC’s from overheating.
There are different sizes of breadboards. Mine is the half-size, with 30 columns.
Tip #1: Use the power lines/rails. Positive (Red) to first row of horizontal row and Negative (Black ) to second horizontal row. I can connect (using jumper cables) the power lines/rails to one power source – one Row (Red to the other side) and the next Row (Black to the other side).
Tip #2: Avoid using all legs of components on a single terminal strip. Avoid this, as you can create a short circuit by having an empty pin on a terminal strip.
Tip #3: Always put the IC (Integrated Circuit) on the center part of the board – straddling pins on each side. Avoid short circuits.
Bus strips are not depicted, I don’t think they are on my particular breadboard
How NOT to break my HERO Board
Current limit of IO Pins is: 40 mA (Milliamp) or .04 A
Limit of barrel jack is 20 volts
HIGH = 5 volts
OHMS Law: Voltage = current times resistance (V = I * R)
For example (voltage is 5 and resistance about 25): 5 = I * 25 (Ohms for each IO pin – based on hardware specs)
I = 5 / 25 = .2A = 200 mA
200 mA is 5 times more than 4o mA, therefore pin/board will be fried
I also don’t want to attach devices which draw more power than the pin can provide. For example, if a pin is 40 mA, then I shouldn’t attach 5 motors each with 10 mA.
Attaching a battery. Positive (red) goes to VIN (Voltage In) and Negative (black) goes to GND (Ground)
Don’t attach barrel connector and USB connector at same time – can overload power and fry the board
HERO Board Anatomy
Main processor chip is the: ATMega 328p
USB Jack: goes to computer USB port
Reset button (next to USB jack). Reboots the board and clears memory.
Barrel jack (power) can be used for external power supply (5V to 20V adaptor). 9V (2A) is recommended.
Type B USB Cable connects USB jack to computer, and receives 5 volts of power from computer
4 LEDS on board: ON; RX; TX; L
-ON – power is on; L – onboard LED turned on by Arduino software; TX (transmit) and RX (receive) – communication between HERO board and another device
Power section of board: Unused pin (for future); 5V (5 Volts); REST (Reset pin – for an external reset button); 3.3V (3.3 Volts); GND pins (2 ground pins) – exit point of electricity in our circuit; VIN (Voltage Input) – additional option for powering up HERO board.
Note: There is an IOREF pins on my board, which is used for XXX. Also, my board only have one 5V pin
Analog signals can be measured. We have a section on board called Analog IN, with pins A0 thru A5. Analog components like potentiometers, sensors
Digital is either ON or OFF. Eg 1 or 0. Eg HIGH or LOW
We have 13 digital pins. Digital input or output of a component. Serial communication pins are 0 (Rx) and 1 (Tx), for communication with other serial devices (eg bluetooth and WiFi modules)
PWM (Pulse width modulation) enabled pins are marked on board with a squiggle next to number. These are commonly known as analog out – eg LEDs and motors
It’s been years since I looked at anything resembling programming. As I’m hyper-associative, my big challenge is immediately understanding the code, as my mind is firing off random questions, that can de-rail thinking.
I think the best is to look at it from multiple perspectives. For example, this whole deal about pin 13. The board has a hole for (digital) 13. The LED on the board is linked to pin 13 – I think. LED_BUILTIN is a constant for “13”, I think. I could enter: pinMode (13, OUTPUT); . What is VOID all about? Does “return something” not include the LED flashing?
See what I mean? My plan is to accommodate my natural tendency by following the program details from inventr, and also cross-reference with documentation from arduino.cc. When I see different ways of describing the same thing, it will start clicking together. My hope is that, over time, it will start sinking in and become easier. In my opinion, this is what active learning is all about. I will maintain engagement and interest by asking questions of curiosity, that are pertinent to current area of focus.
I could opt for just loading sketches, skipping over details unknown to me, and primarily focusing on whatever is the current topic, but I’ve found that catches up to me at some point (during troubleshooting, typically). I need understanding of all elements.
When I cross-reference to another site, I’ll place the URLs at the bottom within my REFERENCE section
Comment section:
I covered this topic in another post. There are two forms of comments, that originate from c programming:
/* This is my comment, which can span multiple lines*/
// This is my comment, which extends from the “//” to the end of the current line (useful for in-line documentation)
Note: I’m impressed with the documentation, included in the sketch, by inventr – it’s actually quite clear – on the 4th reading. LOL!
Pin 13 linked to LED on UNO board
For some reason I had some initial confusion with this. I think it’s because there is reference to a Pin 13, where you attach a wire from #13 to the breadboard and then to an LED. The UNO board also has a red LED. Now, my understanding is that I can (without attaching to the breadboard) reference Pin 13, and it’s going to the onboard red LED.
void setup() {
} Q: What does void mean?
A: I’ll probably understand this more later, but it means that the program is not expected to return information.
In this sketch – it turns a light on and off.
One good analogy is that If I asked someone to turn a light off and on, and they came back saying that they happened to be in the bathroom at the time – that information (I didn’t know) – the bathroom – would be an example of data being returned to the function. I think…
The “setup” part means that this is run each time the unit is powered up, or if the button is pushed on the board
pinMode(LED_BUILTIN, OUTPUT);
Q: What does pinMode mean?
A: You can configure pins to be either input or output. This will make more sense later.
In this case, I want the Pin to do a mode – output something – LED lighting up.
Q: What is a constant?
A: A constant is a way of assigning something to a variable which is then uniform across entire code or within specific sections of code. The concept allows: uniformity; not having to remember the associated answer (in this case: 13); theoretically being able to uniformly changing the answer by just changing the constant value.
Q: Outputting to…:
A: Well… Pin 13 is associated with LED – so, the LED
void loop() {
}
Void meaning it doesn’t return anything. Loop – it loops forever
digitalWrite(LED_BUILTIN, HIGH);
I’ll understand more soon about volts, amps, etc soon.
For now, Pin 13 is a digital pin. I’m telling it to send to LED_BUILTIN (digital pin 13) 5 volts (High) to turn on the light (LED anode)
Voltage 5 volts
delay(1000);
This causes a timed delay – about a second
digitalWrite(LED_BUILTIN, LOW);
In this case, it’s turning off the flow of 5 volts to digital pin 13 (LED Anode)
delay(1000);
More delays – 1 second
Code (sketch) for Arduino – Blink
/* Blink
Turns an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to the correct LED pin independent of which board is used. If you want to know what pin the on-board LED is connected to on your Arduino model, check the Technical Specs of your board at: https://www.arduino.cc/en/Main/Products
modified 8 May 2014 by Scott Fitzgerald modified 2 Sep 2016 by Arturo Guadalupi modified 8 Sep 2016 by Colby Newman
// the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); }
// the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }