Show Posts
Pages: 1 ... 1205 1206 [1207] 1208 1209 ... 1739
18091  Using Arduino / Project Guidance / Re: move rod 30 cm back and forward in a straight line on: July 24, 2011, 10:36:21 am
Get a length (>= 30cm) of threaded studding and couple a motor to one end of it.
Attach your plastic rod to a nut that is incapable of rotation (constrain it in a channel, or stop the rod) and screw the studding into the nut.
18092  Using Arduino / Project Guidance / Re: Arduino Camera Laser Trigger on: July 24, 2011, 10:29:03 am
And the camera is a point-and-shoot, an SLR, a DSLR, a medium-format, an Arriflex, a Red...?
18093  Using Arduino / Project Guidance / Re: move rod 30 cm back and forward in a straight line on: July 24, 2011, 09:51:09 am
Quote
But then I'm still not sure how to get it to move in a straight line
It looks to me like the piston is moving in a straight line.
18094  Using Arduino / Project Guidance / Re: Arduino Camera Laser Trigger on: July 24, 2011, 08:53:58 am
Specification?
18095  Topics / Robotics / Re: Servo motor interfacing on: July 24, 2011, 08:23:22 am
Quote
if(value >= 544)
Doesn't the "Servo.write" method already do this for you?
18096  Using Arduino / Programming Questions / Re: How do i do this?? on: July 24, 2011, 07:29:15 am
Divide an int by an int, result int.
Divide a double by a double, result double.

Cast an int to a double, result double. But it is too late - you've already lost the fraction.
18097  Using Arduino / Project Guidance / Re: move rod 30 cm back and forward in a straight line on: July 24, 2011, 07:02:43 am
Quote
What is the easiest and most inexpensive arduino solution for that?
Tie the rod to a hamster, and use the Arduino to stick a pin attached to a servo into the hamster's derriere.

Seriously, what sort of displacement, and how fast and accurate does it need to be?
18098  Using Arduino / Programming Questions / Re: How do i do this?? on: July 24, 2011, 06:52:52 am
Quote
I am only getting 2 instead of 2.5.
You can't (easily) store a fraction (2.5) in an integer data type.

Quote
I tried println((double)(sum/4))
As before, the position of the cast and the order of execution is important.
"sum" is an "int", and so is 4, so the reulst is also an "int".
Casting the result to a float simply makes 2 into 2.0.
Quote
println((double)sum/ (double)4))
18099  Using Arduino / Programming Questions / Re: How do i do this?? on: July 24, 2011, 05:55:52 am
Quote

Code:
subtracting '0' from the digit character will give you the decimal value of the digit.
Could you give me a code for that so that I can compare it to what I did above. Thanks

Code:
char digit = '7';
int digitValue = digit - '0';
18100  Using Arduino / Programming Questions / Re: How do i do this?? on: July 24, 2011, 05:20:34 am
Well, there are lots of ways.
If all you're interested in is single digits, then subtracting '0' from the digit character will give you the decimal value of the digit.
If you've converted multiple digits into a single int, using atoi, then dividing by successively larger integer powers of ten will help you split the number into individual units.

So, 2345 / 1000 = 2

The modulo operator % is also useful here.
18101  Using Arduino / Programming Questions / Re: How do i do this?? on: July 24, 2011, 04:45:11 am
Sorry, missed a set of parentheses; not much point casting a char to a char!
Quote
Serial.println((char)(output[0]+2));
However, adding 2 to '9' won't get you '11'
18102  Using Arduino / Programming Questions / Re: calculating average from the input on: July 24, 2011, 03:52:14 am
See my reply to your other question.
18103  Using Arduino / Programming Questions / Re: How do i do this?? on: July 24, 2011, 03:46:43 am
Quote
Serial.println(output[0]+2); it will be 2+2
No, it will be '2'+2  - the single quotes are really important.

Quote
Serial.println(output[0]+2);
Here, 2 is an "int" (by default), so the "char" in "output[0]" is promoted to an "int", the addition performed and the result, an "int", printed.
Because  the resultis an "int" and not a "char",a different "version" of "Serial.println" is chosen, and the default format to print an "int" is to print its decimal value.

You could cast the result back to "char".
Quote
Serial.println((char)output[0]+2);
18104  Using Arduino / Project Guidance / Re: Speed control of DC motor on: July 23, 2011, 03:30:58 pm
Ah! Sorry - posted from my phone - couldn't read it properly.
18105  Using Arduino / Project Guidance / Re: Speed control of DC motor on: July 23, 2011, 02:31:00 pm
Quote
analogRead values go from 0 to 1023, analogWrite values from 0 to 128
Have I missed something about only using half the PWM range?
Pages: 1 ... 1205 1206 [1207] 1208 1209 ... 1739