Pages: [1]   Go Down
Author Topic: Variable scope  (Read 536 times)
0 Members and 1 Guest are viewing this topic.
SydneyAust.
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm new to coding the ArduinoNEO
It looks like if I dimension a variable below the loop() command, it is no longer dimensioned within a for-loop below that. 

How can I maintain availability to the data in a variable.  Should all the variables be global?
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6119
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is a NEO?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

A variable is only valid in the function it was declared. To make it valid for all functions declare it at the top of the code before any function.

If you want specific help with your problem please post the code you are having trouble with.
Logged

SydneyAust.
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ahh that would be good - I'll declare everything outside the setup() or loop() for global.

And I think I meant UNO not NEO .. or is it some other TLA ??



*three-letter-acronym
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6119
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Uno isn't an acronym. 
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Monterrey, N.L. México
Offline Offline
Full Member
***
Karma: 1
Posts: 154
Model Railroading & Arduino are Fun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


'UNO' = 'one' in Italian & in Spanish. smiley
Logged

Billy     http://www.z-world.com/operations/gbremer/

When you've eliminated the impossible,
whatever remains, however improbable, must be

SydneyAust.
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

¡Ah, sí!
Logged

Pages: [1]   Go Up
Jump to: