while (true) { irValue = irSensor.Read(); irValue = irValue / 5; if (irValue > 100) irValue = 100; pwm.SetDutyCycle((uint)irValue); }I also added a safeguard so that the value doesn't get bigger than 100 (100 is full-on for pwm).
- Netduino Forums
- → Viewing Profile: Posts: Stefan W.
The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Community Stats
- Group Members
- Active Posts 153
- Profile Views 8352
- Member Title Advanced Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
8
Neutral
User Tools
Friends
Stefan W. hasn't added any friends yet.
Latest Visitors
Posts I've Made
In Topic: Assign Analog input value to PWM output
18 April 2012 - 03:49 PM
To answer "how do you convert an int to an unsigned int", you cast it: (that's the (uint)
In Topic: Electronics 101 book recommendation
17 April 2012 - 09:10 AM
Also not a book, but for me, when I started with electronics, a simulator like LTSpice has been invaluable - you can try stuff without frying things
i.e. test if your transistor switch works and how much current is drawn from the microcontroller etc. But that's just in addition to a book, it obviously does not teach you physics


In Topic: hardware quirk and bugs
12 April 2012 - 06:26 PM
You weren't too slow, your post has more helpful information than mine
and your suggestion about not driving optocouplers/LEDs directly is certainly right.

In Topic: hardware quirk and bugs
12 April 2012 - 03:41 PM
What "input with pullup" means is that there effectively is a resistor between 3v3 & the pin. This resistor limits the current, so using leds to check is not adequate (the current might simply be so low that you don't see the led lighting up), you need a scope or a fast multimeter to check.
There is also no way to turn a digital ouput on 50%.
In Topic: hardware quirk and bugs
12 April 2012 - 01:13 PM
How do you determine this?
IIRC, on startup the microcontroller uses all pins as input with pullup enabled, then, after the startup-routine (bootloader and so on) is finished, the program starts ... so what's in your code will not take effect immediately after boot.
On start up, only pin 3 and pin 7 fire high,
and pin 3 looks like its only 50 percent, but only happens for like 5
seconds. Then the program starts. It looks like a hardware quirk.
IIRC, on startup the microcontroller uses all pins as input with pullup enabled, then, after the startup-routine (bootloader and so on) is finished, the program starts ... so what's in your code will not take effect immediately after boot.
- Netduino Forums
- → Viewing Profile: Posts: Stefan W.
- Privacy Policy