I had thought that low resistance used in the voltage/potential divider would be better but will experiment with your suggested values and beyond! Don't forget though that I had tried the same 'ohms' but with multiple 1/4W resistors in parallel - was that a stupid idea or was there a degree of positive logic behind it that only failed because I used too low resistance values?
I will explore the analogRead function in a bread board setting to see how it works. Thank you. Do you have an opinion about pull-up or is that a red herring?
13.8V is that I was a lad taught as being the 'powered with alternator' voltage on a vehicle's power 'bus' - In my planning I allowed for some variance ether way - although it's a new bike so shouldn't be to random.
This question(s) must have been answered before however I can't find definitive answers anywhere.
I am trying to do a project to add LED indicators, daylight running lights with riding modes (day time, night time, braking etc) to my motorbike. Using an Arduino Nano
to drive RGB LEDS which will be Red (tail lights) unless the indicator is functioning when using PWM I'll add some Green light to make Amber.
1. I am using a Buck transformer to bring the bikes 12V-15V power down to 5V - this works. I am toying with the idea of fusing with resettable fuses for additional protection.
2. Powering the RGB LEDs will take a MOSFET device as some of the LEDs strips and others will draw more than the total amount the Arduino can supply on its digital output pins (I have ordered a few 4 port MOSFET boards and also some components to try making my own)
so am confident that part of the project will work - assuming PWM will run through the MOSFET
Again each Digital pin will have a resettable fuse that will trip above 40mA (I hope)
3. Now I need to take a 'signal' from the indicator (and another from the horn) circuits to see if the indicator (horn) is on or off. As all my D pins are being used for driving LEDs I plan to use the analog pins to sense if there is a 5V+ input or 0V.
This means I need to be very careful as I can't have 12V run straight into the analogue pin. I have tried using a simple (standard two resistor circuit) voltage divider with 60ohm in R1 and 20ohms in R2 which does take the power from say 14.5V to 3.6V but the resistors get hot (they are only 1/4W rated). I tried putting two 120ohm in parallel for R1 and two 40ohm in parallel for R2 thinking that would share the load - but it still gets hot, and this is just measuring it with a multimeter - is this right?!? It seems to be a very basic circuit and no-one else seems to complain about resistors 'melting'…
I have on order some LD1117S33CTR 15V to 3.3V voltage regulator chips which should solve the problem
but I am still baffled why my other circuit isn't working. Maybe too great a voltage drop maybe I should do the drop in stages and daisy chain voltage dividers together? Do you suppose that taking a feed off the indicators / horn will effect their function?
I'd appreciate your thoughts on why the voltage divider is getting hot, and also if I ought to put a Zener diode in there to cap the voltage at 5V+?
The second part of the problem is that I need to check if there is power to an A? pin and then perform an action. I have been able to do a simple 'read' on digital ports but not sure if that is the same on analogue? Can someone please show me a bit of code that can see if 5V+ is present on an analogue INPUT pin? And if I need pull-up set?
Why PWM? Selecting the right current limiting resistor will get the balance right, unless you want other colour variations. Do you need white? If not, red/ green LEDs would suit.
The fuses protect your wiring, not the electronics. So should be close to the battery.
I think that all of the LED strips will require switching MOSFETs. You can allow to run one indicator LED at 20 mA from an Arduino pin. 220 Ohm resistor in series between Arduino pin and FET gate, 10k resistor from Arduino pin to ground to keep FET off while booting.
Rubbish!Each pin will have a 220 Ohm resistor in series to whatever it drives. What has 40 mA got to do with anything?
"Analog" pins A0 to A6 are digital pins.
What problem?and How? (will it effect the bikes electrics).
You are quite right - in order to get this to work I have had to be conservative on which colours on the RGB LED to PWM and which to do a simple on off. On the rear RGB LEDS it needs RED and Amber as the two functional colours - RED is easy as its 100% on and Green and Blue off. Amber is achieved by having RED full on and Green 45% appx. I have tried using resistors but it isn't as good as using PWM.
On the front RGB LEDS it has white light (all on 100%) and Amber, so again the Green will be on PWM. I would like to make the White light a bit blueish but don't have enough pins, and it would also mean reducing Red and Green intensity to make the blue show up - according to the colour tables at least!
The whole fusing thing is an idea I pinched from the Ruggeduino https://www.rugged-circuits.com. Automotive applications can be challenging because of the variable power and spikes etc. It might not be necessary but it's giving me some good soldering practice
Usage of MOSFETs all round - Agreed - I simplified my project statement otherwise it would read like War & Peace... Thank you for the resistor ideas - I shall try it.
50mA is what the spec sheet says is the max current supplied by a pin. The ruggedised Arduino people use a 40mA resettable fuse. Sounds like it's not necessary but since I have them...
It's an expensive bike full of technology. For some elements of the project I am not messing about with simple home brew circuits (voltage dividers) but getting fully supported, properly designed and manufactured bits for that purpose i.e. automotive spec components. Playing with different types of voltage dividers / regulators and the like is so that I develop an understanding of the fundamental principles (or try too...).
The bike has CANbus technology and my experience on messing about with CANbus is that you need to test your components. As a very simple example installing an LED sight light without a restive load will trigger CANbus to think the bulb is blown
likewise carelessness can lead to interference with the vehicles safe operation e.g ABS, traction control, cruise control, throttle by wire, EMU etc, etc. I'm not saying my project will interfere with all this but I am definitely going to check and test!