MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

icon
Avatar
Julesta
Posts: 129
Hello and I´m sorry, because in the new 9.0 MB there is a PWM for several pins of arduino that are PWM. I see that it can be 0-255 Ok. But : But how can use a value between 0 and 255. 255 is the default value, but if I want to use 100 because I wnt that the LED bright was less. How can do it?. Or, better: could you explain me the use of PWM in Mobiflight?:rolleyes: :rolleyes: :)

Thanks at avance.
2021-08-18 22:37
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
For example to control Gauges with special servos..... OR to dimm a LED.

Lets make some simple LED examples.....

If you use the Pin ( Device settings WITHOUT the PWM Checkmark) then it is a regulary 1/0 Pin like in the past.....
Means Value "0" is OFF and Value "1" ( or very other value like 2,3,5,99999 ) represent "ON" In other words. Pin is "0 Volts" or "5 Volts" or it is LOW or HIGH.

If you choose PWM in the setting of the Device and upload to the Board then it is a PWM Output !
Now there is a acceptable value Range from 0 (OFF) to 255 (Full Bright ) withall the stepps between.
E.g. a value of 128 means LED light with 50% intesity.

Usage:

A) Fixed
You can for example light a LED always on half Power ...... If Offset is e.g. 1/0 then you say in transfrom if($=1,128,0) or more logical $*128
Offset 0 means 0*128=0 So LED is OFF ...... If Offset is 1 then 1*128=128 . So LED is on 50%

B ) with multiple indications.
For example a LED should be OFF if Flaps are UP should be dimmed if Flaps are on Position 1 and should be Light full Bright if Flaps are 2 or Higher ( Lets say Flaps Offset show 0-5) .... then you would say if($=0,0,if($=1,128,255)) ..... So 0 at 0 , 128 at 1 , and 255 anytime else.

C ) Linear to a Offset Value.
Lets say a Offset goes from 0 to 255.... Then you can directly use the offset. LED growing brighter as higher the offset is.
If Offset Range is different..... Then you must "transform" it to a 0-255 Range.
For example a Offset (goes from 0-32535 ( like Gear Position) ) then it can have 32536 Numbers .... We need a scale from 0-255 ( so 256 numbers) .... So Devide 32535/256 = 127.... To get the correct dividing factor to syncro the scale !

Means if you NOW say $/127 then the Offset now goes from 0-255 ( instead 0-32535) ..... Means if you release the Gear then the LED going brighter and brighter until it reach full bright after gear is down !


( I know senseless examples..... I just want to explane in a easy way how you casn use this )
Good Luck !
2021-08-25 16:15
Avatar
Julesta
Posts: 129
Thank you my friend. Excellent explanations, as ever.:thumbup: :thumbup:

Best regards,
2021-09-07 21:35
Avatar
sergio1956
Posts: 5
Supporter
Hello, when you say "choose PWM in the setting of the Device and upload to the Board" want does exactly mean "upload to the board"?
I choose PWM and I modified output values for a less brilliant led but nothing happened.
Under 128 LED is off, upper is on. No changes in light intensity. Where is my mistake?
Thank you
2021-12-08 00:36
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Upload means you UPLOAD the current Device Setting to the Board.

So if you need a LED you create a new Device ( In settings-mobiflight Board) You choose a Pin that allow PWM .... Enable the Checkmark..... And then you press UPLOAD!
( Without Upload the new Device not exist on the Mega ! )

*******
About Problem:
Please tell us what Pin you use.... And what electrical Setup you use (Resistor?)



Problem sound strange..... It must be already PWM.... Else the LED would be ON same way if Value is greater then 0 ...... So if 128 change the Situation then it must be PWM already.
Good Luck !
2021-12-08 13:32
icon