***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
1 day ago 00:22:27 6
#033 Learn Ten Home-Based Exercises and Pain Relief Positions for Lumbar Spinal Stenosis
1 day ago 00:02:16 1
Spoofing Pokemon GO iOS & Android - UPDATED Pokemon GO Spoofing with Joystick, Teleport, Auto Walk
3 days ago 00:06:37 0
Pink Floyd - “Another Brick in The Wall “ PULSE Remastered 2019
3 days ago 00:02:12 0
Los Santos Street Life – A Day in the Hood 🏙️🔥 | GTA V Online
3 days ago 00:02:09 0
Monopoly GO Hack iOS & Android - How to Get Monopoly GO Free Dice Rolls 2025
4 days ago 00:02:13 0
Coin Master Hack iOS & Android - How to Get Coin Master Unlimited Spins 2025
4 days ago 00:08:26 4
Russian Su-34 AIRSTRIKE on Kherson! FAB-500 Bombs DESTROY ENEMY Military Hangar
4 days ago 00:02:10 0
Delta Executor Mobile iOS & Android - NO KEY Roblox Executor Mobile 2025
5 days ago 00:59:06 0
Amnesia META | NOSTALGIA SCARES! | Full Conversion Mod, Playthrough Gameplay w/ facecam
5 days ago 00:19:22 0
Doorways: The Underworld | PSYCHOPATH’S MIND | (Part 1) w/ facecam, Gameplay Playthrough
5 days ago 00:00:39 0
Atomic Sunrise Festival - Hawkwind - Hurry on Sundown
6 days ago 00:18:01 0
The Forest | AS ABOVE, SO BELOW! | (Part 9) w/ facecam, Gameplay
6 days ago 00:11:13 0
Five Nights at Freddy’s | WHAT DOES THE FOX SAY?! | (Night 3) Indie Horror Game w/ facecam
6 days ago 00:16:36 0
MIND: Path to Thalamus | CRYSTALS AND THE GIANT! | (Part 6) w/ facecam, Gameplay Playthrough
6 days ago 00:02:08 0
8 Ball Pool Hack/MOD APK iOS & Android - How to Get 8 Ball Pool Aim Hack Tool 2025
6 days ago 00:18:08 1
Vanessa Trump’s Stunning Transformation Since She Left Don Jr. Is Causing A Stir
6 days ago 00:02:19 1
Baseball 9 Hack/MOD APK iOS & Android - How to Get Baseball 9 Free Gems and Coins
6 days ago 00:02:30 2
H-1B (“16 tons“ song parody)
1 week ago 00:00:16 0
He wasn’t supposed to be there #shorts
1 week ago 00:08:30 2
Wizard n’ Champion Episode 1
1 week ago 00:27:02 1
I built a SUSPENSION BRIDGE in Minecraft Create Mod!
1 week ago 00:28:39 1
I built a STEAM TRAIN in Minecraft Create Mod!
1 week ago 00:32:30 0
Papo & Yo | THE CALM AFTER THE STORM... | (Part 7/End) w/ facecam, Gameplay Playthrough
1 week ago 00:26:10 0
4PM | SPLIT DECISIONS... | Gameplay w/ facecam, Indie game about decisions