I am new in this field i need a simple single LED flasher/Solid circuit that accepts 3 types of input signal from a circuit one is positive +5v to gnd and other is -5v to gnd when +5 signal input to arduino it should solid ON and when -5v signal input the LED starts flashing LED at rate of 2sec and when no signal (below 2v) LED off.Please reply at email@example.com
Hello, I actually have a similar question, so if possible, please write the solution here or at firstname.lastname@example.org
If i read input signal on analog input and program it with if and map condition is it possible to achieve ??.
Before that you will have to translate your input voltage to a positive only voltage between 0V and +5V.
Here is an example making this:
LED diver.fzz (3.8 KB)
You will have to connect ADC signal to an analog to digital converter of your ATtiny.
And write a code that reads this signal and make your LED blink in function of voltage level.
The file you have attached is not opening up which environment will open it?
This is not a part file, it is a project file… Click File then Open from the top menu.
For your level translation problem a simple resistor level translator will get you to ttl levels and a 74hct level translator will get you to the cmos levels that the 328 in an Arduino wants. Basically this circuit should do the necessary translation:
+5V — 8K2 resistor ---- input to a 74hct14 schmitt trigger inverter — 10k resister ---- gnd / -5v input.
The resistive divider provides about 2.7V (a ttl high is < 2.4V) when the input is gnd and about .45 V (ttl low is > .7V) when the input is -5V. The 74hct14 believes (as does ttl) that anything less than .7V is low and anything above 2.4V is high. The Arduino thinks less than .7V is low but somewhere around 3.5 V is needed for a high (and 2.7 V from the divider may not register as a high!). You could also connect an Arduino analog input pin in place of the 74hct14 and measure the analog voltage there as it is in the correct range for an Arduino analog input. Note that you also need to connect the unused 5 inputs of the 74hct14 to either ground or vcc not leave them float and it needs to be 74hct (for ttl inputs) not 74hc to work.
Peter Van Epp
why using an IC when 3 resistors do the job?
Mostly for noise margin and speed of the edge reasons. The noise margin is already pretty low since the high and low levels are near the margins (and much worse than a typical chip output’s
margins). As well if the input transition is slow the schmitt trigger input will clean it up. If the
2 resistor trick works (which I doubt, the high level is I think too low to trip the input of a 328 from the data sheet., although I haven’t tried it) more the power to him. I tend to prefer solid designs though.
Peter Van Epp
Can provide schematic diagram with code?
Please, could you post the schematic of you solution?
I do not understand how it works. How do you manage to get 3 states (LED ON, blink, OFF)?
For your information, the solution I proposed is designed to be connected to an ADC, so there is no notion of high/low level.
I may have misunderstood the initial problem, but when I see that LED blink rate is 2s (0.5Hz), I doubt that speed is a real problem for FaizanHamayun.
Ah, there has been a miscommunication here, I wasn’t trying to solve his entire problem, only the part of converting a signal going from -5v to ground in to one that can be fed to a logic input expecting 0 to 5v as that is the only unusual part of the problem.
Peter Van Epp
Attach please find the schematic in which it has two bi color LED for status one is red it glows continuously when battery under charge and green glows when battery is fully charged.
When no battery no LED glows.
I need something else i need yellow glow when no battery,green flashes 2sec when batt under charge and green solid when it is full.
it is a lithium ion charge controller single cell.
You likely need a comparator (the lm293 is a reasonable one) to separate out the three states high (probably 5V) charging, low (likely 0 volts) charged and 2.5 volts via a high resistance voltage divider for no battery. Pin 7 in the drawing would connect to 10k or
larger resistors like this
At pin7 you will see 0V for battery present and charged, 2.5 volts no battery and 5V battery present and charging. One comparator needs a threshold of about 3.5V (and likely hystersis, the app notes show how) the other needs a threshold of around 1.5 volts. That gives you 2 digital inputs to a micro that drives a 3 wire red/green led (the led currently there won’t work) from microcomputer output pins. As with the original poster assuming an Arduino as the micro, the blink example provides a starting point for writing the code.
Peter Van Epp
As Wali was perhaps going to suggest, this can also be done with just the 2 resistors (to guarantee the floating output is at 2.5 volts when no battery is present) and an analog input pin on the processor to detect one of the three states by input voltage and it could also use the current led if you feed the led a 50% duty cycle output to produce the orange color along with high for red and low for green and change the pin driving the led to an input pin to turn off the led for the flashing requirement. Since you only need 2 I/O pins on the processor something much smaller than a 328 in a typical Arduino Uno) would work as long as it supports analog input pins (I’m more used to PICs than Atmel’s small cpus).
Peter Van Epp
Thank you for your comment Vanepp
In fact, I wanted to ask for FaizanHamayum to post the datasheet of LS2811, but after re-read his post I have found the answer to my question.
And I agree with you, a smaller µC would be enough.
I suggest you to have a look at ATtiny chips. They have a analog to digital converter and they are smaller than a 328.
Please suggest a code along with circuit diagram.
This is difficult to help you if we do not know the µC you will use (Atmel, PIC, …).
And I am sure you can find examples of reading analog value from ADC.
As well you could use Fritzing to make yourself a schematic to post and have reviewed, just modify the one for the battery charger to add the two resistors to pin 7 and add in whatever processor you are going to use connecting its analog input pin to pin7 on the charger IC (along with the resistors). The current leds (if you choose to use them) each need an output pini, other wise you need to connect whatever leds you are going to use to output pins with an appropriate current limiting resistor. If your are planning on using an Arduino the examples in the Arduino IDE (such as blink which blinks a led, which is one of the things you need to do) would be an appropriate starting place to make your changes. I expect there are examples of analog input code there as well.
Peter Van Epp