I don't know how many cap sensors you are trying to create, so you need to make sure that the number of entries is correct.
Or, you can use pointers and the new operator.
ah, ok. I would prefer to use pointers since speed is an issue and it has been on to do list. I have never used pointers before though. Is there anything in particular in this context that I should try to look up to read more on it? I am not even sure what to search. "using pointers to populate objects...?"
number of sensors is set by variable: numberOfSensors
I would prefer to use a loop so I can change this as I go, I need to prototype it as I go, so I will start with 4 sensors then 8 then 20, etc.
I would prefer to use pointers since speed is an issue
Pointers are not necessarily faster than other means of data access.
In this case, you would make some minor changes:
CapacitiveSensor *cs_sensor[numberOfSensors];
for(int i = 0; i < numberOfSensors; i++)
{ // Down here where it belongs!
cs_sensor = new CapacitiveSensor(capSenseSend,sensorPin*);* * }* void setSensorValue() { // Down here where it belongs! * for(int i = 0; i < numberOfSensors; i++)* * { // Down here where it belongs!* letters.setCurrentReading(cs_sensor*->capacitiveSensor(50)); _ } }*_
I would prefer to use pointers since speed is an issue
Pointers are not necessarily faster than other means of data access.
In this case, you would make some minor changes:
CapacitiveSensor *cs_sensor[numberOfSensors];
for(int i = 0; i < numberOfSensors; i++)
{ // Down here where it belongs!
cs_sensor = new CapacitiveSensor(capSenseSend,sensorPin*);* * }* void setSensorValue() { // Down here where it belongs! * for(int i = 0; i < numberOfSensors; i++)* * { // Down here where it belongs!* letters.setCurrentReading(cs_sensor*->capacitiveSensor(50)); _ } } [/quote]_ hmm this seems to throw an error that I can't find much info on: invalid conversion from 'const byte' to 'uint8_t' for the line cs_sensor = new CapacitiveSensor(capSenseSend,sensorPin);
You need to post your current code, so that we can see that you made all the required changes, correctly. And so we can replicate (and solve) the problem more easily.
PaulS:
You need to post your current code, so that we can see that you made all the required changes, correctly. And so we can replicate (and solve) the problem more easily.
I did, its on the last page might have missed it, other than the changes you suggested. here it is again though just in case:
Delta_G:
Just follow exactly what the compiler told you. The setSensorValue is missing an array index there.
seems to stop way before that on: cs_sensor = new CapacitiveSensor(capSenseSend,sensorPin); with error: error: invalid conversion from 'const byte*' to 'uint8_t' I gave it an array index like so just now: * *void setSensorValue(){ for(int i = 0; i < numberOfSensors; i++){ letters.setCurrentReading(cs_sensor[i]->capacitiveSensor(50)); } }* * same error. thats is the problem, no idea what the error means, and can't seem to find anything on google for it
earlier I mentioned I set that line with the error to: cs_sensor = new CapacitiveSensor(capSenseSend,sensorPin*);* which seems like what it is suppose to be, however farther down I get: error: request for member 'setCurrentReading' in 'letters', which is of non-class type 'Letter [2]' for: *_ <em>*letters.setCurrentReading(cs_sensor[i]->capacitiveSensor(50));*</em> _* so I am not sure if this is correct thing to do.
Go through your code and fix all these. If you are going to use the array you'll need to put the index with it. Get all that fixed, and post us new code to look at.
Go through your code and fix all these. If you are going to use the array you'll need to put the index with it. Get all that fixed, and post us new code to look at.
I would fix it if I knew what was wrong to be honest. this section of code has compiled fine in the past, not sure what would be wrong with it. I don't even know how to look up what that "illegal conversions from byte pointer to uint8_t" error is, google isn't giving me anything.
Googling for pointer and c++ gives a ton of stuff. Many many tutorials that explain what a pointer is. Once you know that it should be obvious that you can't convert one to an intended type.
But even without that, I told you how to fix it. pin numbers is an array. You're using it without an index. That won't work.
Delta_G:
Googling for pointer and c++ gives a ton of stuff. Many many tutorials that explain what a pointer is. Once you know that it should be obvious that you can't convert one to an intended type.
But even without that, I told you how to fix it. pin numbers is an array. You're using it without an index. That won't work.
maybe I am misunderstanding but pinNumber is an int, not an array. are you looking at ledPin or sensorPin maybe? those are different and in fact an array.
And I'm betting this line will give you an allValues not declared in this scope error. I don't see it declared anywhere anyway.
EDIT: Found it in the previous code, but it was commented out there.
I am kind of fixing it as I go, probably a bad idea. Reason is I am converting this from messy functions to more Class based. Those will be replaced by the classes, but I feel like I need to get the classes working first since they are so new to me, then I can make my way down the list. Right now I cant even get the class to pass correct values. But I guess I will read more about pointers....