Returning null values while developing code

Aloha Arduinians 8)

Another newbie to the crowd and fired up my first 'ino with the blink-test; woot!

So here's the fun question: I would like to start coding for later deployment of sensors (ph, temp, etc) however I do not actually have the sensors yet. I'm wondering if I could code the Arduino to simply spit out a null value (or preset value) if the code is good.

Ideally I would like to use 0 as an error value (ie: no input received, blah blah) and a preset value as a confirmation that all is well (which would later be replaced by the true sensor value).

Thoughts?

And no, I don't have an existing code to link up... yet. :slight_smile:

I'm wondering if I could code the Arduino to simply spit out a null value (or preset value) if the code is good.

Maybe. All you can emulate is reading the sensor. Getting a value from the sensor, and pretending to have gotten a value from the sensor, have little to do with whether the code that deals with that value is any good, though.

You could do something like this:

#define analogRead  fakeARead
#define digitalRead fakeDRead

unsigned int  fakeAVal[] = { 128,64,512,... };      /* Fake analog inputs */
unsigned char fakeDVal[] = { 0,0,0,1,1,1,0,1,... }; /* Fake digital inputs */

int fakeARead(int pin)
{  return fakeAVal[pin];
}
int fakeDRead(int pin)
{  return fakeDValu[pin];
}

Or just have the fake*() functions always return zero.

mikeyyc:
I'm wondering if I could code the Arduino to simply spit out a null value (or preset value) if the code is good.

What do you mean by "code" in this context?

Thanks Morris! Just what I needed :grin:

At a later date, will replace that code-bit with sampling the true values from the sensors. Perfect; I can get on with coding the rest of the project. Merci beaucoup!