So Im trying to get my accelerometer to talk to my FET shield /arduino pro mini to drive strings of LEDs, the code isnt mine and i have had a hell of a time getting everything wired up to this point. Looking at the code there is something that i think is driving my issue, that being whatever is being initialized on A0 .
What does this mean typically?
"const int statLED = A0;"
And is there a channel 0 on the pro mini?
#include <SoftPWM.h>
const int chan0 = 2;
const int chan1 = 3;
const int chan2 = 4;
const int chan3 = 5;
const int chan4 = 6;
const int chan5 = 7;
const int chan6 = 8;
const int chan7 = 9;
const int accelX = A3;
const int accelY = A2;
const int accelZ = A1;
#define SINGLE 1 #define ALL_BUT 2
float aX, aY, aZ;
int brightLevel = 9; //5% is still very noticeable. 40% or more is basically full brightness
const int statLED = A0;
//Timers
//==============
long startTime, endTime;
long lightSwitch, checkDirection;
//==============
//Growth/decay control
//==============
long maxTimeBetween = 3500; //In ms. Max time of no movement before we stop rotation completely
float shortestDelay = 25; //In ms. Min amount of time = fastest spinning that looks good. Don't go below about 25ms.
float timeBetweenChannelChange = 0;
//Pick your growth rate. Found by spreadsheet
//float growthRate = 1.0015; //for 2000ms
float growthRate = 1.00086; //for 3500ms
//float growthRate = 1.0006; //for 5000ms
//==============
float currentAccelReading = 0; //Used to see if there is new movement
int lightUpMode = SINGLE; //Start hat up in single LED mode
float oldMag = 938.0;
int channelNum = 0;
I think for a full understanding you should also be aware that the Arduino system has a great many predefined names (of which A0 is one example) which the compiler converts to numbers that are meaningful for the microprocessor.
th3chainrule:
So that does not necessarily mean that there is something physically attached to A0 right?
Such as an led.
Variable names only have meaning to the person writing the program. Naming a variable "LED" doesn't tell the Arduino anything, except that there is a variable named "LED". You could name it "Bob" and have the same effect.
I would assume if someone wrote code naming a variable "LED" and then assigned a number representing a pin to that variable, they expected a LED to be attached. Wouldn't you?
th3chainrule:
So that does not necessarily mean that there is something physically attached to A0 right?
Such as an led.
The name implies that there is an LED connected to the pin, otherwise why use that name, but there may actually be nothing connected, as in the case where a floating analogue input is used as a seed for the randonSeed() function.
The name also implies that the pin is being used as a digital output because under normal circumstances you would not read from an LED. Although it is possible to use an LED as an input it would be unusual. Looking at the corresponding pinMode() command for pin A0 would make this clearer, but note that pins default to being inputs so there may not actually be a corresponding pinMode() command.