Show Posts
|
|
Pages: [1]
|
|
2
|
Using Arduino / Microcontrollers / Re: Output high at bootup (need to stay low)
|
on: December 01, 2012, 08:21:41 am
|
|
Do you use pull-down resistors on those 2 pins?
When the MCU resets, all i/o pins go into Tri-State (High Impedance) and then default to input pins (Also high input resistance) until your sketch defines them as output pins.
Using a resistor (one for each pin, 10K/47K or so) to ground will make sure the pin stays LOW unless explicitly driven HIGH by the output.
Hope this helps, Guido
|
|
|
|
|
4
|
International / Deutsch / Re: IRLZ34N geht kaputt
|
on: November 05, 2012, 06:59:38 am
|
|
Versuch mall ein wiederstand and der Gate (Zwissen gate und pin, 10-47 ohm oder so etwas). Es koennte sein dass das MOSFET durch ringing die gate uberlasstet. (Die wiederstand wird die turn-on/off-time etwas langer machen, sollte aber kein problem sein).
Hope this helps, Guido
|
|
|
|
|
6
|
Using Arduino / Programming Questions / Re: Serial.available acting funny
|
on: October 22, 2012, 10:59:16 am
|
|
Couple of remarks, hope they can help.
First, the line ' //}' seems weird, with the comment marks it does NOT compile. Taking out the '//' compiles ok.
Next, does it actually print the "length" string? If x is not inside your range, nothing is done, whatever you receive.
Then, the line 'float distance = analogRead(1);', again hmm, analogRead returns a int, not a float. Not critical, but not clean.
But, most critical, you are not looping yourself, but using the Arduino background code to repeatedly call loop(). This means you are not in full control over what the system is doing. Even in the Arduino the microcontroller 'rule' the main function never exits is still a good one to follow.
Now, i am not sure, but it looks like the serial buffer is reset upon entering loop().
If i place the main block in a while(true) { .. } loop, it seems to work; at least it sees the incoming data etc.
Oh, and finally, the lines // say what you got: Serial.print("I received: "); Serial.println(incomingByte, DEC); make no sense, inComingByte is initialise to 0 and never set.
HTH, Guido
|
|
|
|
|
7
|
Using Arduino / Programming Questions / Re: sprintf ?
|
on: October 06, 2012, 06:35:32 pm
|
As AWOL indicated, the stdlib (i think it is stdlib) linked in by Arduino does not support floats in the sprintf. One way around this would be to tinker with Arduino IDE to include the full/extended stdlib to get the float working in sprintf. Another way is to convert the float using : dtostrf(floatVar, minStringWidthIncDecimalPoint, numVarsAfterDecimal, charBuf); Example : void setup() { Serial.begin(19200); }
void loop() { float F = 1.25; char buffer[16]; dtostrf(F,5,2,buffer); Serial.print("Float : "); Serial.println(buffer); //Do not loop while(true) {}; }
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Re: Strange problem with "sprintf"
|
on: September 28, 2012, 10:39:28 am
|
|
Yes, the sprintf implementation used in Arduino seems to have a problem with floats. Not sure if it is code or the wrong module is being linked in or what.
However, the avr-libc function dtostrf() does work and you could use that. It will convert a float to a string, but it cannot include text like with sprintf. So you will have to print the segments separately or use an extra buffer and do the sprintf to insert the string in the text.
The function has to following parameters : dtostrf(floatVar, minStringWidthIncDecimalPoint, numVarsAfterDecimal, charBuf);
Hope this helps, Guido
|
|
|
|
|
9
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: Push button problem again
|
on: March 23, 2010, 05:45:23 pm
|
|
Hi.
Just my 2 cents worth.
You have a line : digitalWrite(buttonPin, HIGH); Why would you write to this pin, you just defined it as a INPUT?
Also, there are 2 lines : buttonState = digitalRead(buttonPin); int buttonState = bouncer.read(); This will make things very confusing. I am sure the first line should be deleted, as you use the Bounce class.
Also, are you sure you are pressing/releasing/pressing the button inside 400 ms? As your code will only trigger if it sees HIGH - LOW - HIGH, within 400 ms?
For debugging, i would insert a line to print the time difference, probably after the line : if (buttonPushCounter % 2==0 ) { , something like : unsigned long delta = millis() - pressed_time; Serial.println(delta,DEC);
Hope this helps, Guido
|
|
|
|
|