Set Default Digital inputs to Low? How? bad Analog value?

How do I set the digital inputs to low on default? :confused: I’m using an optical sensor that inputs voltage when it senses an object, I’m using this on the EDU Mini RC, so is there a solution to setting it low? the sensor doesn’t work like a switch so it doesnt short the Sig to Gnd.

:confused: Also how do you printf the Analog inputs? I have 3 analog channels and this is how I printf mine:

printf("rc_ana_in01 %3d, rc_ana_in02 %3d, rc_ana_in03 %3d

Is this correct? because im getting readings that look like this:
rc_ana_in01 135, rc_ana_in02 143, rc_ana_in03 151 :frowning:

so please help me out. Thanks!

Wait, is this an analog or a digital sensor? Is it perchance one of the banner sensors that we got in the kits in 2004?

Nope, not that sensor, its a reflective object sensor. this sensor is analog, its ouput voltage varies with different refletive surfaces. I was thinking of putting a resistor to keep the gate closed, and if the sensor picked something up, it would have opened the gate due to a weak resistor.

First up, you’re probably going to need an inverter for the sensors, they sell them in a little chips at Radio Shack (hopefully). The digital I/O lines are hardwired to be pulled high unless grounded I believe, can someone else confirm this?

As far as the analog inputs, those variables are actually addresses used by a function to sample the ADC, this function is Get_Analog_Value(). It should used like this:

printf("rc_ana_in01 %d, rc_ana_in02 %d, rc_ana_in03 %d
",Get_Analog_Value(rc_ana_in01), Get_Analog_Value(rc_ana_in02), Get_Analog_Value(rc_ana_in03));

Good luck!

EDIT: Also, Get_Analog_Value() returns the value of the ADC you choose, so you can store the information in a variable for use later like this:

unsigned int sensor_var;

sensor_var = Get_Analog_Value(rc_ana_in01);

YAY! I’ve just tried that and works like a charm, thanks! :smiley:

The inverters sounds like a good invesment. I will consider that option.

Is there still a way to make the Digital Inputs default to low? Because the Sensor im using has very little collecter-emitter voltage, as high as 0.4Volts, the NOT gates need a minimum of 1.5 Volts input for it to declared a high input. Any other ways to make this work? I’ve googled up the Not gates but nothing to my specifications.

It would be best if the Mini RC could do a pull down by default.

The other way to do this is…making them all analog? would that work?

I don’t think so.

Yes, I believe it would.

Well, from your description of the sensor, it seems that you could plug it in to an analog input, and then simply use it as a sort of digital sensor in the following manner (let’s pretend the sensor is plugged into analog input 1):

#define TRUE !0
#define FALSE 1
#define OBJECT_SENSOR_INPUT rc_ana_in01
unsigned char objectNearby;
/*You may need to use "<" if I misunderstood how the sensor works*/
    objectNearby = TRUE;
} else {
    objectNearby = FALSE;

You can then use the objectNearby variable to check for the presence of the object and you can change the THRESHOLD_VALUE to make the sensor more or less sensitive.

What is sensor you are trying to interface? Can you post a link to or copy of the mfg. spec sheet? The 0.4V output does not sound correct.

The sensor belongs to OPTEK technologies, OPB742D and OPB606A are the two sensors Im using.

Here are the Sensor Data,

The voltage picked up from my Multimeter reads DC 0.4V maximum using a 1.5V double A battery source.

Also, in hopes of getting rid of the use of Inverters, I’ve tried instead of setting INPUT; at the end of the IO’s, I set them to 0;

IO4 = IO5 = IO6 = IO7 = IO8 = IO9 = IO10 = INPUT; <---------Before
IO4 = IO5 = IO6 = IO7 = IO8 = IO9 = IO10 = 0; <---------After

And I’m still not sure if it works, although the voltage between SIG and BLK is gone, I havnt found a way to trigger it so it goes high.

Check out this application note.

See figure 1 and figure 3.

The collector current of the phototransistor is relatively low.

The OPB606 is 500 uA this can pull down 5V thru a 10k resistor.
The OPB704 is 50 uA this can pull down 5V thru a 100k resistor.

I do not know what the input circuit of your controller looks like, but I would guess that the OPB606 might work with a direct connection as long as pullup is 10k or greater.

The OPB704 will very likely need the circuit shown in figure 3.

Those devices are exactly suited to being connected directly to the RC’s digital inputs. They don’t produce voltage; their output is the equivalent of a contact closure. Tie the “E (2)” pin to ground, and the “C (1)” pin to the digital input.

(And don’t mess with the IO direction settings. What they do is determine whether a given pin is an input or an output. There is always a pullup resistor on the pin.)

Awesome! It works!:smiley: Thanks so much for all your help.

Problem solved…I’m sure I’ll have more problems later on when we start, but yeah! Awesome!