Show Posts

Pages: 1 [2] 3 4 ... 14

16

Using Arduino / General Electronics / Re: Calculating LED current

on: September 09, 2012, 03:53:26 am

You sure? You need the forward voltage drop, normally about 1.8V, subtract this from the supply voltage then divide this by the current to get the resistance. Remember you can only get 40mA from a pin and the 3V3 supply on many arduino modules is limited.
Made a mistake, Vf = 1.8v, If = 100mA. I'm not powering this from the arduino's regulator, but a seperate one.



17

Using Arduino / General Electronics / Calculating LED current

on: September 09, 2012, 03:28:12 am

I have an infrared LED i would like to control, the datasheet says 5V100mA but i want to control it with 3.3v.
How do i calculate the current at 3.3v? I knew this once but i forgot.



22

Using Arduino / Programming Questions / Get array value index by searching value

on: September 01, 2012, 12:18:31 pm

In a project i'm making, i need to use arrays. Now i have a question: Is there a way to find a value's index just by searching for the value?
For example:
int arrayVals[] = {2, 4, 8, 3, 5, 1};
Now for example when i input "8" into a function, i need it to return the index of 8, which is 2. How would i go about doing that?
Oh and how can i get the length of an array?



25

Using Arduino / Programming Questions / Re: RGB to HEX

on: August 16, 2012, 04:59:10 am

Maybe a poor choice of words on my part, technically it should be integral (or integer if you prefer). But never mind.
Already figured it out, this is the new code i'm using: int integral = (int)someFloat; //integral is the number to the left of the decimal point int fraction = (int)((someFloat  integral)*10.0); //remove integral to leave just fraction, fraction is the 1st number to the right of the decimal point char timechar[5] = {0}; sprintf(timechar,"%d.%d Seconds",integral,fraction); uoled.TextGraphic(5,40, 1, 150, 1, 1, timechar, 1);
And now my stopwatch function is working, thank you!



26

Using Arduino / Programming Questions / Re: RGB to HEX

on: August 15, 2012, 12:18:13 pm

I ran into a problem and i can't solve it. I'm using this code: while (counting == 1){ if(digitalRead(leftpin) == LOW){counting = 0;} if(counting == 1){someFloat = (float) someFloat + 0.1;}
int exponent = (int)someFloat; //exponent is the number to the left of the decimal point time = (float)exponent; //remove the exponent to leave just the fraction. int fraction = (int)(someFloat*10.0); //fraction is the 1st number to the right of the decimal point char timechar[5] = {0}; sprintf(timechar,"%d.%d Seconds",exponent,fraction); uoled.TextGraphic(5,40, 1, 150, 1, 1, timechar, 1); delay(100); }
And now when it's counting it does fine, until it reaches one second, after that it does this: 1.10 1.11 1.12 1.13 1.14 ~ 1.19 2.20 2.21 ~ 2.29 3.30 Does anybody know what is causing this?



28

Using Arduino / Programming Questions / Re: RGB to HEX

on: August 11, 2012, 01:04:17 pm

It gave me some errors during compiling so i had to change the code to this: float someFloat; float time = 0.1; int exponent = (int)someFloat; //exponent is the number to the left of the decimal point time = (float)exponent; //remove the exponent to leave just the fraction. int fraction = (int)(someFloat*10.0); //fraction is the 1st number to the right of the decimal point char timechar[5] = {0}; sprintf(timechar,"%d.%d",exponent,fraction); uoled.TextGraphic(5,40, 1, 150, 1, 1, timechar, 1);
But now it just prints "0.0" to the screen...



29

Using Arduino / Programming Questions / Re: RGB to HEX

on: August 11, 2012, 12:44:16 pm

Okay, thanks. That worked. Now i'm trying to print a value with 1 decimal using this code: float time = 0.1; char timechar[5] = {0}; sprintf(timechar,"%d", time); uoled.TextGraphic(5,40, 1, 150, 1, 1, timechar, 1);
But on the screen, it shows up as '13107'



