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 5V-100mA 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.
18  Using Arduino / Programming Questions / Re: Get array value index by searching value on: September 01, 2012, 12:44:22 pm
If your array is ordered, you can shorten search times by doing a binary search.

It's not ordered.
19  Using Arduino / Programming Questions / Re: Get array value index by searching value on: September 01, 2012, 12:42:24 pm
Will this code work if i expand the array during execution of the code?
20  Using Arduino / Programming Questions / Re: Get array value index by searching value on: September 01, 2012, 12:30:24 pm
To do inverse lookup you need to traverse the array
-code-

Thank you. Now what happens when i search for a value that isn't in the array?
21  Using Arduino / Sensors / Re: Wrong temp sensor value when using Ethernet shield on: September 01, 2012, 12:19:57 pm
I use Shieldlist to find info about shields.

According to their info, your shield only uses D10-D13.
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?
23  Using Arduino / Sensors / Re: Wrong temp sensor value when using Ethernet shield on: August 19, 2012, 08:09:57 am
If you're using the basic code, just change
Code:
float read_temp = kty(0);
to
Code:
float read_temp = kty(2);
and connect the sensor to analog pin 2.
24  Using Arduino / Sensors / Re: Wrong temp sensor value when using Ethernet shield on: August 19, 2012, 08:07:18 am
Could you provide some more information, like what pins you're using.

If you're using A0 like in the tutorial: That pin is used by the ethernet shield.

Try changing the pin to A2-A5
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:
Code:
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:
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?
27  Using Arduino / Programming Questions / Re: RGB to HEX on: August 11, 2012, 01:16:36 pm
Never mind, already figured it out. Thanks!
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:
Code:
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:
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'
30  Using Arduino / Programming Questions / Re: RGB to HEX on: August 05, 2012, 01:14:20 pm
so will not in a char

How would i do it then?
Pages: 1 [2] 3 4 ... 14