logical control of led with sensors

Thread Starter

varunme

Joined Sep 29, 2011
60
In a series of sensors, with corresponding LEDs of which if the corresponding sensor got intercepted the LED goes 100%, other wise its 50%, it goes on 100% till the adjescent sensor is intercepted, how can we implement this idea ?, i used various codes with bit shifting, gates etc , none is working, anyone have a better idea ?
 

praondevou

Joined Jul 9, 2011
2,942
Your description is lacking a lot of information. For example voltages from the sensors, how many sensors, LED current etc.

Doesn't sound to difficult. Could be done with simple FFs, one for each sensor.
Using the SET inputs to activate the outputs , the outputs would then reset the adjacent FFs via their RESET inputs.

You then need an oscillator which is simply enabled/disabled by the output of the FF. Could be a CMOS oscillator with a toggle FF after it to achieve 50%.

100% is always on, that would be the /Q output of the toggle FF. e.g. a 4013.
You then need driver for the LED, transistor etc.
 

ErnieM

Joined Apr 24, 2011
8,058
I...the LED goes 100%, other wise its 50%...
100% and 50% of what?

If brightness, take sample LED, drive with current to get desired 100% brightness. Record current. Repeat for 50% and also record current.

Based on supplied voltage and LED ON voltage calculate resistor to yield 100% current.

To get 50%, compute ratio of current to give 50% over current to give 100%. Use this ratio as a pulse width control ratio to get LED average current to match 50% current.
 

praondevou

Joined Jul 9, 2011
2,942
To get 50%, compute ratio of current to give 50% over current to give 100%. Use this ratio as a pulse width control ratio to get LED average current to match 50% current.
Somehow I got confused :D:D:D


When I saw 50% I automatically thought "50% duty cycle PWM"... Let's see what the OP says... If he comes back
 

spinnaker

Joined Oct 29, 2009
7,835
yes, by PWM
I want to attain these through an uC.
The sensors are photodiode/phototransistor.
Then first you need to get PWM working. Have you done this? Bit banging should be pretty easy. For 100% on you could simply make the port high always. For 50% toggle the pin off and on.
 

Thread Starter

varunme

Joined Sep 29, 2011
60
XOR ing the portc input to portd is making the conditions except the one which , the LED has to be at 100% till the adjescent sensor is intercepted.
 

Thread Starter

varunme

Joined Sep 29, 2011
60
Code around that special case with a conditional test to provide 100%
i used

Rich (BB code):
input_state = portc; // store the input value
portd |= input_state  // set to high the outputs that represent an input that has 1
 
portd ^= ~input_state;   // invert the portd bits when the same bit in input_state is 0 , leaves bits with 1 in input_state unchanged
delay_ms(a);
portd ^= ~input_state;  // invert the portd bits when the same bit in input_state is 0 
delay_ms(b);
can you suggest to implement the idea i said, that is to hold on 100% till an adjescent sensor is intercepted ? My code goes to 50% as soon as the obstacle from the sensor is removed
 
Last edited:
Top