How do I set the digital inputs to low on default? 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.
Also how do you printf the Analog inputs? I have 3 analog channels and this is how I printf mine:
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:
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?
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 THRESHOLD_VALUE 500
#define OBJECT_SENSOR_INPUT rc_ana_in01
unsigned char objectNearby;
/*You may need to use "<" if I misunderstood how the sensor works*/
if(Get_Analog_Value(OBJECT_SENSOR_INPUT) > THRESHOLD_VALUE) {
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.
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.)