| Arduino Forum ::  Members :: DerekErb
 Show Posts Pages: 1 [2] 3 4
 16 Using Arduino / General Electronics / Re: Very basic resistors question on: February 25, 2013, 11:56:02 am Thank you for the tutorial. I learned a lot!The first thing I learned is that the "lf" in my LED sticker stands for Forward Current.Would you know what the "Uf" stands for?...I got a bit confused when we got to the actual formula part of your tutorial.I see the +5V output and I see that we want to calculate R_LIMIT for 20mA.I don't see how you jumped from the +5V above the R_LIMIT to the 3.0V in the R_LIMIT calculation rather than using 5V.In your calculation 3.0V / 20mA = 150 Ohms. 3/20 = 0.15 so I assume that somehow 20mA gets converted to 0.02 in our calculation. We take 20 and divide it by 1000 as we're working with milliamps?Why didn't we do 5.0V / 20mA to give us 250 Ohms as we have 5 volts coming out of the Arduino?I therefore have a (red) wire going from the 5V of the Arduino to the (longer) Anode wire of my LED; a (black) wire going from the (shorter) Cathode wire of the LED to one end of the 150-270 Ohm resistor and another (black) wire going from the other end of the resistor to the GND pin of the Arduino.My LEDs, except for the RGB ones, only have 2 pins. Where would I attach the wire going from the LED to the digital or analog output pin on the Arduino?
 17 Using Arduino / General Electronics / Very basic resistors question on: February 25, 2013, 11:22:32 am I am an old software guy who is trying to (re)learn all of this basic electronics and hardware with Arduino.I have a pretty basic question, the answer to which will help me in all my future endeavours, it's about calculating which resistor(s) I need for any given sensor or output device I connect to my Arduino.Let's say I'm plugging in to the 3.3V output on my Arduino...I have a LED which says "Uf 2V lf 20mA" and another which says "Uf 3V lf 20mA"How do I figure out what size resistor I need to plug in? What's the magic formula I need to apply?And I always plug the resistor in to the GND connector of the LED (going back to the GND pin on the Arduino) right?Many thanks.
 18 Using Arduino / Project Guidance / Re: A siren louder than a buzzer on: February 21, 2013, 08:39:40 am I am a software guy who is (re)learning about the hardware side of electronics slowly but surely.I haven't worked with transistors or relays yet.Would this sort of thing do the trick?http://snootlab.com/lang-en/tinker-it/229-t000200-thermistor-module.htmlHow and where would I connect this to the Arduino and the siren? In other words between which pins and +/ground?Many thanks
 19 Using Arduino / Project Guidance / Re: A siren louder than a buzzer on: February 21, 2013, 08:01:49 am If I go for G_M's mini-siren what do I need to put between my Arduino and it?I assume I have to put something between the 5v out on the Arduino and the Mini-Siren to "boost" the output?Do I put this magical piece of kit between the line and the Arduino or between the ground and the Arduino?I'm more used to going the other way and putting resistors between the Arduino and the "weaker" object (LEDs, buzzers, ...).Maplin will ship to France so I will order a few of these things. But I want to make sure I have everything (hardware) to make this work.Many thanks all!
 20 Using Arduino / Project Guidance / A siren louder than a buzzer on: February 20, 2013, 06:25:08 pm I'm playing around with a networked sensor alarm. I've got the sensors (smoke, gas, temperature and humidity).I want this to replace our smoke alarms by lighting up (LEDs), sending messages (Twitter, EMail, SMS, ...) and making lots of noise.I know how to light things up and send messages.But I need to make a lot more noise than I know how to at the moment. I have a KPEG110 piezo buzzer and a COM-11089 PCB mount speaker and I can make tones on these. But this is nowhere near the sort of volume I need for an alarm.What can I use that I can easily hook up to my Arduino and will fit in a nice tiny form factor?Thank you in advance for any advice and suggestions.
 21 Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 11, 2013, 11:42:32 am iPow()? Duh! I wish I thought of that!Obviously that is the more elegant, and flexible, solution.I hate you Arrch! I had put my code away for the day and you have made me go back to it!Works perfectly. Thanks.
 22 Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 11, 2013, 07:33:33 am Thanks to the notes here I've replaced my pow(10,iDigs) call to a for loop as follows:Code:    // Separator = 10 to the power of number of decimal places    long dSep = 10;    for (int i = 1; i < iDigs; i++) {      dSep *= 10;    } This allows me to safely pass the number of decimal places as an argument to the function.Any other ideas?
 23 Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 11, 2013, 07:20:01 am Whoops. You're right PaulS I originally had returned the char as a pointer rather than passing the char as an argument. That didn't work as I wanted and when I put the char in as the argument I forgot to change the returning variable to void.I do realise that pow() is a float (double) function. However I am unaware of any other function in Arduino which would allow me to return 10 to the power of X. Obviously I can replace it with a for loop multiplying 10 by itself X number of times. But that just seems a lot less elegant and less logical to me.If I use pow(10,2), pow(10,4), pow(10,6), ... I always get full integer results even without doing an int(pow(10,2)), ...However if I use pow(10,iDigs) I always get a "rounded down" result regardless of the value of iDigs.Thanks.
 24 Using Arduino / Programming Questions / Re: sprintf problem on: February 11, 2013, 07:14:09 am I was unaware of the problems with floats and sprintf within Arduino. Krodal's comments pointed me in the right direction and I started looking for problems of that type here. I found even more info, and a solution I was able to apply, in a different thread here:http://arduino.cc/forum/index.php/topic,146638.0.htmlMichinyon : All of my sprintf arguments are perfectly fine within C and C++. The formats I mentioned, %f, %2.2f, %2f and %d are all valid and should have worked. It's Arduino that has a bug with %f not me.  Obviously using %d on a float is going to produce spurious values. But that was out of desperation.  Krupski : Thank you for your extremely helpful suggestion of pde.jar. I will look in to that possibility in the future. However this sketch is the beginnings of a project which is going to soon run up against the memory space wall and I can't spare the 1.5k for this one.  Thanks all and I, like many others I assume, look forward to the day that %f works properly within the standard Arduino libraries.
 25 Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 11, 2013, 07:07:40 am I was having similar problems with sprintf and floats (http://arduino.cc/forum/index.php/topic,148024.msg1112201.html#msg1112201). I was unaware of the problems with floats, sprintf and Arduino.Arrch certainly pointed me in the right direction and I wrote a function using his principles. It works fine and does just what I want it to do THANK YOU ARRCH!However I now have a different bug... for some reason I can't pass the integer value of the number of decimal places I want to display. Have a look at the code below. You'll notice that if I pass the number of decimal places as an argument to the function (FtoChar) I lose 0.01 in the values. But if I hard code the decimal places inside the function (FtoChar2) it works fine.After a bit of debugging I found out where the problem is and I'm almost more confused. If you uncomment my DEBUG lines you'll notice that I get different results from what should a simple calculation of 10 to the power of 2. If I set iDigs to the value of 2 within the function I get 100 (as I should). If I pass iDigs as an argument, with the integer value of 2, to the function then 10 to the power of iDigs becomes 99 instead of 100 thereby screwing up my actual values.Code:////////////////////////////////////////////////////////// FtoChar//// Float to char//// fVal  Float value to be converted// iDigs Number of decimal places// cF    Char var to be modified//char* FtoChar(float fVal, int iDigs, char* cF) {    // Separator = 10 ˆ Number of decimal places    long dSep = pow(10, iDigs);// DEBUG// Serial.print(F("FtoChar dSep: "));// Serial.println(dSep);    // Display value = floal value * separator    signed long slVal = fVal * dSep;    sprintf(cF, "%d.%d", int(slVal / dSep), int(slVal % int(dSep)));}////////////////////////////////////////////////////////// FtoChar2//// Float to char (forced 2 decimal places)//// fVal  Float value to be converted// iDigs Number of decimal places// cF    Char var to be modified//char* FtoChar2(float fVal, char* cF) {  // Force number of decimal places to full 2  int iDigs = 2;  // Separator = 10 ˆ Number of decimal places  long dSep = pow(10, iDigs);// DEBUG// Serial.print(F("FtoChar2 dSep: "));// Serial.println(dSep);      // Display value = floal value * separator  signed long slVal = fVal * dSep;  sprintf(cF, "%d.%d", int(slVal / dSep), int(slVal % int(dSep)));}void setup() {  float fTemp = 18.90; // Temperature (Celsius)  float fHum = 34.80;  // Humidity (percentage)    char cMsg[254], cTemp[8], cHum[8];    // Init serial monitor  Serial.begin(9600);  delay(1000);    Serial.print(F("Temp : "));  Serial.println(fTemp);  Serial.print(F("Humidity : "));  Serial.println(fHum);  Serial.println();  // Should output Temp: 18.90C - Humidity: 34.80%  // But it ouputs Temp: 18.89C - Humidity: 34.79%  FtoChar(fTemp, 2, cTemp);  FtoChar(fHum, 2, cHum);  sprintf(cMsg, "Temp: %sC - Humidity: %s%%.", cTemp, cHum);  Serial.println();  Serial.println(F("FtoChar:"));  Serial.println(cMsg);  Serial.println();    // Correctly outputs Temp: 18.90C - Humidity: 34.80%  FtoChar2(fTemp, cTemp);  FtoChar2(fHum, cHum);  sprintf(cMsg, "Temp: %sC - Humidity: %s%%.", cTemp, cHum);  Serial.println();  Serial.println(F("FtoChar2:"));  Serial.println(cMsg);  }void loop() {}
 26 Using Arduino / Programming Questions / sprintf problem on: February 10, 2013, 04:41:34 am This is one of those moments where I have just been looking at the same piece of code too long and can't see the error which must be right in front of me. I even slept on it and came back to it this morning...Here's my code snippet:Code:  char cInfo[64];  float fTemp;  float fHum;    // Read temperature & humidity  fTemp = dht.readTemperature();  fHum = dht.readHumidity();  // DEBUGSerial.print(F("T: "));Serial.print(fTemp);Serial.print(F(" - H: "));Serial.println(fHum);  // Format output  sprintf(cInfo, "%02u/%02u/%4u,%02u:%02u:%02u,%.2f,%.2f", day(), month(), year(), hour(), minute(), second(), fTemp, fHum);  // DEBUGSerial.println(cInfo);  // Output info to file  file.println(cInfo);Normally this code should be used to print out the current date, time, temperature and humidity as a comma-separated list to a file. But when I looked at the file the temperature and humidity values were question marks. That's when I started adding the debug serial outputs to see. The problem happens just after the sprintf call.The result of the above code looks like this:T: 18.90 - H: 34.7010/02/2013,10:26:13,?,?The first line confirms, to me, that the temperature and humidity values are being read properly and stored in their float variables.The second line shows me what was just written to the file.The problem appears to be in the sprintf conversion. I have tried using "%f", "%2.2f", "%2f" and "%d". That last one was a desperate measure and produced spurious numbers.I'm sure this is something simple I'm missing... but I just can't see it.Thank you in advance for any suggestions or directions you may point me in.
 27 Using Arduino / Sensors / Re: AM2302 (DHTT) : Could it really be this easy? on: January 31, 2013, 09:19:54 am Thanks for the confirmation michinyon.Is there any way to work around the "flaky humidity measurements"?Is there a better, or more precise, humidity sensor?Thanks.
 28 Using Arduino / Sensors / AM2302 (DHTT) : Could it really be this easy? on: January 31, 2013, 06:19:00 am I recently received a new AM2302 temperature / humidity sensor. It's a fully-assembled, wired, version of the DHT22. It seems to be almost too simple to implement. There are 4 wires: one for 5v power (connected to a built-in resistor), one for data and one for ground. There's a fourth wire, in between the 2nd and 4th, which is supposedly useless. But I've heard that it works better if that is also plugged in to ground.I found the DHT library and example code, copied and pasted a few routines in to my basic code. I plugged the 4 wires in to my mini breadboard and then to my Arduino Uno.In less than a half an hour I had a fully operational temperature / humidity display program running (hardware & software).It just seems too easy. I must be missing something. I am counting on you experienced Arduino engineers to tell me what I have forgotten or not adjusted for.My whole project is here:http://fritzing.org/projects/arduino-am2302-on-a-mini-breadboard/
 29 Using Arduino / Programming Questions / Re: Arduino Keeps Restarting within Setup() on: January 13, 2013, 05:57:45 pm I went through and F() macroed all of my serial.print() and serial.println() calls with constant strings.It works!Thank you all for your help, advice and suggestions.New version attached...
 30 Using Arduino / Programming Questions / Re: Arduino Keeps Restarting within Setup() on: January 13, 2013, 01:56:08 pm QuoteWhich Arduino are you running this on? The 328-based Arduinos have 2K of SRAM. The SD library needs 1/4 of that for the buffer to read from/write to the SD card.I should have said that up front. This is running on the Arduino Uno with the Ethernet Shield.I also will be testing it on an ArduinoPOE  and then on an Arduino Uno with a WiFi Shield.I understand the memory management problems of storing tons of literals in to SRAM at run time. I had not (yet) seen any mention of F() macros in the examples I've been reading. I will certainly try that...Aside from the code being less elegant and hogging memory do you think that is actually part of the execution problem?
 Pages: 1 [2] 3 4