Тёмный
No video :(

A Brief Introduction to C++ Classes 

HO Scale Rio Grande in the San Luis Valley
Подписаться 1,5 тыс.
Просмотров 204
50% 1

WARNING: This video assumes a basic knowledge of Arduino programming and it is not for the faint-hearted. I am providing it to give interested viewers some insight into the workings of the LED class. If you do not care about the nuts and bolts, you can skip this video entirely and simply use the LED class. I will demonstrate one application of the LED class in an upcoming video on grade crossing flashers.
LED terminology: An LED has two connections: the anode and the cathode. Current flows through an LED in just one direction: from the anode to the cathode. The anode is always connected to positive voltage and the cathode is always connected to the ground. The longer lead of an LED is almost always the anode. If there is a small plastic flange at the base of the LED, the flange is flattened on the cathode side.
The Arduino turns LEDs on and off by controlling the voltage applied to the LED leads. An LED is turned on by applying +5 volts to the anode and zero volts (or ground) to the cathode. An LED may be turned off in either of two ways: (1) by applying zero volts to both the anode and the cathode, and (2) by applying +5 volts to both the anode and the cathode. In both of these, there is no net voltage across the LED and current cannot flow. (Note that applying zero volts to the anode and +5 volts to the cathode will not result in current flow: the LED - which is a Light Emitting DIODE - will not allow reverse current flow.)
When LEDs are connected in parallel (as for example, in multicolor LEDs), they may be connected as “common anode” or as “common cathode.” A common anode connection supplies positive voltage to all LEDs at once, and the individual LEDs are switched on and off by controlling the connection to ground. A common cathode connection connects all LEDs to ground, and LEDs are switched on and off by controlling the positive voltage supply.
-----------------------------------------------------------------------------------------------------------------------
Links to items mentioned in this video. (Note: I am NOT endorsing any particular product(s), nor am I compensated by or connected to any of the companies mentioned.) I do NOT guarantee that these links will give you the best available price! Consider these links to be a starting point for your search.
Source code listings: github.com/RJW... There are four files of interest: Classes_1.ino, Classes_2.ino, Classes_3.ino, and Classes_4.ino. The .ino extension means these files were created by the Arduino IDE, but they are simple text files and may be opened by any text editor.
Arduino Nano Clone: www.amazon.com...
Prototyping Circuit Board: www.amazon.com...
Jumper wires: www.amazon.com...
LEDs: www.amazon.com...
120 Ohm resistors: www.amazon.com...
Arduino IDE Download: www.arduino.cc...
The most recent version (as of the release date of this video) is 2.1.0. In this video, I am using version 1.8.13. You can download legacy versions of the IDE by scrolling down the page.
-----------------------------------------------------------------------------------------------------------------------
This video was edited using Shotcut for Linux. Video footage and still images were recorded using a Galaxy A10e phone and a Nikon D7100 camera.

Опубликовано:

 

26 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 3   
@maxg4958
@maxg4958 Месяц назад
Thank you. Now add a header file :) Nice effort.
@rwissbaum9849
@rwissbaum9849 Месяц назад
This video has been online for over a year, and yours is - as you noticed - the *first* comment I've received. Thanks! Obviously, the next step is to create a library, but since this video has been viewed less than 200 times in a year, I doubt that there would be much interest in a how-to video. However, if you want to create a library, here's how: First, put all the definitions (class definition and constant definitions) into the header file and all of the code into a .cpp file. Second, create a keywords.txt file (this tells the IDE how to format the on-screen text) and a library.properties file (which is just some text describing the library.) Third, if you *do* *not* want the library to be read-only, create a file (it may be empty) named .development. Next, create a folder under the libraries folder in your default sketch directory and give the folder the same name as your library. Create a sub-folder called src and place the header file and all supporting .cpp files in the src sub-folder. Then place keywords.txt, library.properties, and optionally .development in your library folder. Once this is done, you can include the library in your sketch in either of two ways: (1) add the compiler directive #include to your source file, or (2) in the IDE menu, select Sketch/Include Library and then select your library from the menu list. The header file should include a few compiler directives to prevent recursive inclusion - otherwise, your code could blow up. Study some of the supplied library header files for examples. Thanks for watching!
@maxg4958
@maxg4958 Месяц назад
@@rwissbaum9849 I appreciate the detailed response, though I know how to do it :) As we know, having a class as header and implementation files, makes the class more 'independent' from where it is used. As for number of views, it is a self-perpetuating system; no views = low ranking; more views higher ranking.
Далее
Refurbishing an Inexpensive Passenger Car
15:22
Просмотров 8 тыс.
Only I get to bully my sister 😤
00:27
Просмотров 21 млн
Oh No! My Doll Fell In The Dirt🤧💩
00:17
Просмотров 3,7 млн
The coolest robot I've ever built!
19:40
Просмотров 4,6 млн
Building Downtown Deco's Classic American Block
27:57
Replacing a Missing Freight Car Underframe
14:49
Просмотров 1,7 тыс.
HO Scale Structure Makeover
15:31
Просмотров 1,6 тыс.
The Art of Code - Dylan Beattie
1:00:49
Просмотров 4,7 млн
You can learn Arduino in 15 minutes.
16:34
Просмотров 10 млн
8x8x8 LED CUBE WITH ARDUINO UNO
6:46
Просмотров 15 млн
Only I get to bully my sister 😤
00:27
Просмотров 21 млн