Posts

Showing posts from July, 2021

Using GIT with Arduino

Image
  What is GIT? The term GIT doesn't actually mean anything. It was made up. But what it is, is a "version control system". That sounds complicated, but really all it boils down to is that it saves versions of your files, and gives you a way to revert back to old versions - if necessary.  It also provides a way for multiple developers to work on the same project, and even to keep the same project 'in sync' between computers no matter where they are. Where do I get it?  In order to use GIT, you need to install it. Many IDE's come with it pre-installed, but unfortunately, the Arduino IDE does not. You can find downloads for Windows, Mac, or Linux here: https://git-scm.com/downloads I will note, however, that GIT is generally a Command-Line tool. There are GUI's also available on the same website. If you need a GUI, then you can get one there. You should first learn the basic commands for GIT before using a UI though.  Once you download and install it, you can

Programming Arduino with Regular Expressions

Image
Download Code Here:  What is a Regular Expression? A regular expression is a string that uses characters within the string to define a pattern and provides a function to test another string to find matches to that pattern. Probably the simplest regular expression is just a string with no special characters. You can use regular expressions with Arduino by adding a third party library to your sketch. You do that using Tools->Manage Libraries Then, search for RegEx in the Library Manager. Install Regexp by clicking the install button. This will download the required files and put them into the default library location defined by your IDE. You can find the location under File->Preferences if you changed the default, but the default on Windows is C:\Users\<your_user_name>\Documents\Arduino\Libraries  If you look in your library location, you'll find a folder called Regexp that contains the required header file for this library and some other folders with the source code and

Why your 1TB hard drive doesn't have 1TB space.

Image
 I was recently on the market for a new thumb drive to create a portable Linux machine. I was looking for the fastest available thumb drives, and one of the most recommended thumb drives for this type of application is the SanDisk Extreme Pro. The specs look pretty good for a portable Linux drive, since this is basically an SSD in a USB thumb drive. However, if you're anything like me, the first thing you do when you're thinking about buying anything is to go read the reviews and look for any common complaints that may indicate a common issue with whatever your buying.  The very top review for the SanDisk Extreme Pro right now reads: "I paid for 1 TERABYTE. I need to use 1 TERABYTE. Why on Earth does the drive only actually come wih (sic) 920 GB? And, WHY ARE CUSTOMERS NOT INFORMED? *Eighty gigabytes* is an enormous amount of storage to lose." Being around computers for as long as I can remember, I already know that a 1TB drive doesn't show up on my computer as 1T

Coding C++ with generic functions

Image
What is a generic function? Download Code Example Here A 'generic' in C++ terms is similar to an int, double, or String,  - except it means 'any type'.  They provide a way to write code that will work with any data type - even those that haven't been defined yet. This means you can write a function that doesn't know in advance what data type you'll be putting into it so you can give it ints, doubles, or even strings. It's up to you.  The way you declare this generic type is with the following syntax: template <class anyClass> So, a full function might look like this: template <class anyClass> void swapVals(anyClass &a,anyClass &b){   anyClass temp;   temp = a;   a=b;   b=temp; } In this example, you can pass any 2 variables of the same type, and no matter what type they are, their values will be swapped.  For instance, if you add this code to  template <class anyClass> void swapVals(anyClass &a,anyClass &b){   anyClass t

Structs, what are those?

Image
  Download Code Example Here You might not ever come across a struct, but you might still want to know what they are. They're basically the predecessor to the 'class', and before object oriented programming became a thing people used to use them a lot. They're still around, and in C++ a struct and a class are very similar except a struct's members are public by default. The basic form of a struct looks like this: struct user{   String userName;   String superSecretPassword;   int someNumber;       }; In this example, you've defined a struct called 'userr' that has the fields userName, superSecretPassword, and someNumber in it.  This struct is a type - similar to an int, or a string you can declare a variable to be of type customer  like this: user currentUser; Now, you can access the fields you created in your struct like this: struct user{   String userName;   String superSecretPassword;   int someNumber;   };   user currentUser; void setup() {   // put

What's the point of pointers?

Image
  Download Code Example Here One of the things that most confuses people about C++, are pointers. They add a lot of flexibility to your application, but with flexibility comes complexity. With any luck, I can shed some light on what they are, and how to use them in your code.  What is a pointer? A pointer is just a number that represents an address in memory. That probably seems too simple since pointers are one of the most commonly feared things about using a C based language, but that's really all they are.  How do you use a pointer? If you declare a variable like this int MySpecialNumber = 5; then you get the address of MySpecialPointer with the & operator. So &MySpecialNumber tells the compiler that you want the address of the MySpecialNumber variable.  You can try it out with this simple sketch: int MySpecialNumber = 5; void setup() {   // put your setup code here, to run once:   Serial.begin(9600);   Serial.print("address of MySpecialNumber: ");   Serial.pri