***Learn to program and prototype with Arduino now! Join our membership.***
***We designed this circuit board for beginners!***
Kit-On-A-Shield:
FOLLOW US ELSEWHERE
---------------------------------------------------
Facebook:
Twitter:
Website:
________________________________
So let me ask, what is a pointer? Well, a pointer is a variable that holds the memory address of another variable. Hmm, okay, let’s break this statement down. The first part says, a pointer is a variable. Now, hey, I kinda like this part the best, because probably like you, I’m super familiar with variables. In the Arduino programs that I write, I use variables all the time like a constant byte variables for pin numbers or integer variables for different sensor readings or float variables for some type of precise calculation. I mean, the list goes on. I mean, variables are everywhere in my code. Well, pointers are variables too. So you might actually know a lot more about pointers than you actually realize. So let’s talk about a couple things. First, pointers point to a specific data type. So just like an integer variable is designed to hold integer values and not like float values, an integer pointer is designed to point to an integer variable, not a float variable. Declaring a pointer is super similar to declaring any other variable. If I wanted to declare a float variable, I need the data type and the name of the variable, like float temperature, right? So now I got a variable called temperature and it’s gonna hold a float value. If I want to declare a pointer, I need the data type the pointer variable will point to, the name of the pointer variable and an asterisk right before the name. So here we have a pointer pData that will point to an integer variable. Now listen, I know what you’re thinking. What the heck is that asterisk for? That asterisk is called the dereferencing operator. It’s also known as the indirection operator. It’s used when declaring a pointer so that the Arduino IDE knows that this is no regular variable that this is a pointer variable. And as you’ll learn, pointer variables get handled differently than normal variables. And the asterisk tells the Arduino ID, “Hey, I’m not just some regular variable, I’m a pointer variable.“ So anytime you declare a pointer variable you need to use that asterisk in front of the pointer variable’s name. Pointers also have the same naming rules as variables. The name of the pointer can be composed of upper and lowercase letters, digits and underscores. You can’t start the name of a pointer variable with a digit and you can’t use any reserved keywords for the pointer name like int or true. One final thing to point out about this naming. Do you notice I started the name of the example pointer with a lowercase P? By convention, the name of a pointer starts with either a lowercase P or ptr, followed by the name of the variable it points to. This is meant to help inform the people reading the code that, hey, this must be a pointer variable because it starts with a lowercase P. So if we have an integer variable named data then by convention, a pointer to this integer variable would be named pData or ptrData. Again, a convention is just something everybody kind of agrees upon. If you do it differently in your code your code is still gonna run okay, but other developers who read your code may get a little confused. All right, so let’s review what we know about pointers so far. Pointers are variables. Every pointer must point to a specific data type. When declaring a pointer, you use an asterisk before the name. Pointer variables have the same naming restrictions as normal variables. By convention, Pointer names start with a P followed by the name of the variable they point to. All right, so now you know that a pointer is a variable that holds the memory address of another variable. This is a really important idea to try to get in your head but you’re probably really fuzzy about, well what is a memory address and what is the use of a pointer? I’m not sure I get any of this. That is perfectly alright. This is kind of gonna be a a long discussion that we have as we develop the understanding of what pointers are and how to use them. In the next lesson, we’re gonna start talking a little bit more about memory addresses.
***About Us:***
This Arduino lesson was created by Programming Electronics Academy. We are an online education company who seeks to help people learn about electronics and programming through the ubiquitous Arduino development board.
***We have no affiliation whatsoever with Arduino LLC, other than we think they are cool.***
1 view
255
78
3 days ago 00:55:23 1
What Did Charles Hall Discover About TALL WHITES Alien Residents?
3 days ago 01:05:38 1
SKINWALKING OWLS, WATER SPIRITS, BLUE LADIES AND SILVER UFOS (SN 18 EP 33) TRUE PARANORMAL STORIES
3 days ago 00:29:19 3
Загадка Зеркальной Вселенной: Хиральность на Земле и в Космосе
4 days ago 00:03:49 1
Battling a Dead Battery? TOPDON BT100 is Your Ultimate Weapon! - YouTube
4 days ago 00:02:35 1
8 Ball Pool Hack iOS & Android - UPDATED 8 Ball Pool MOD APK with Aim Tool App 2025
4 days ago 00:03:12 1
Spoofing Pokermon GO - How to Get Pokemon GO Hack iOS & Android with Joystick, Teleport 2025
5 days ago 00:02:42 1
Pokemon TCG Pocket Hack iOS & Android - How to Get Poke God, Free Tickets with Pokemon TCG MOD APK
5 days ago 00:31:50 1
The Insane World of Mega Rich Pastors
6 days ago 00:32:17 2
The Dark World of Megachurches
6 days ago 00:07:16 1
Новости ВИП прорубь.Недорого
7 days ago 00:02:32 2
Dragon Ball Legends Hack/MOD APK iOS & Android - How to Get Unlimited Chrono Crystals in 2025
1 week ago 00:14:08 2
U.S. Nightmare Became a REALITY: Russia Took Iran Under Its Military and Economic Protection
1 week ago 00:02:15 1
Coin Master Hack iOS & Android - How to Get Coin Master Free Unlimited Spins 2025
1 week ago 00:00:00 1
Exploring An ABANDONED School And Old Hospital - Abandoned Places | Abandoned Places UK
1 week ago 00:00:00 2
Exploring Kiki’s & Lieutenant Packard’s ABANDONED HOUSE With EVERYTHING LEFT BEHIND & A Classic Car
1 week ago 01:01:55 3
GREY ALIENS, BLACK SHADOWS AND PALE WHITE CREATURES (SN 18 EP 31) REAL PARANORMAL EXPERIENCES
2 weeks ago 00:03:38 1
Tired of Dry Air and Sleepless Nights? Here’s the Smart Humidifier That Has Your Back! - YouTube
2 weeks ago 00:02:42 1
X2 (5/5) Movie CLIP - This Is the Only Way (2003) HD
2 weeks ago 00:09:30 1
Крах Зеленой повестки в Германии.Зеленый идиотизм без солнца и ветра
2 weeks ago 00:02:24 1
Delta Executor Mobile iOS & Android Tutorial NO KEY - The Best Roblox Executor Mobile in 2025
2 weeks ago 00:02:32 1
8 Ball Pool Hack/MOD APK iOS & Android - How I Got 8 Ball Pool Aim Hack/Guideline Tool in 2025
2 weeks ago 00:12:51 1
The Stunning Collapse of 23AndMe
2 weeks ago 00:07:29 1
Микроволновка на колесах.Тесла игнорирует безопасность пассажиров
2 weeks ago 00:02:23 1
How to DO Block Blast Glitch iOS & Android - Get HIGH SCORE with Block Blast Hack/MOD APK 2025