Loading...
  Show Posts
Pages: 1 ... 327 328 [329] 330 331 ... 454
4921  Using Arduino / Project Guidance / Re: Arduino to tablet computer. on: August 18, 2012, 05:51:59 pm
Basically, the arduino hardware generates data, and I'd like to display that data in a more appealing format than a cheap low-resolution LED screen would give me.

Implementing it as a web app gives you the maximum flexibility for supported clients. You could either implement a web app entirely on the Arduino (probably not sensible if you intend your user interface to do anything non-trivial) or put your web site elsewhere and have it pull up data from the Arduino via any protocol you like e.g. SOAP/HTTP.
4922  Using Arduino / Programming Questions / Re: Arithmetic question on: August 18, 2012, 08:51:42 am
Well, when they are handled, the values reside in the memory right? So i think "stored" is also correct. Everything are stored in the registers, its just how the cpu interpret them.

It's only semantics, but 'handled' is the more correct term. In other words, what code is generated in order to evaluate the expression you coded.
4923  Using Arduino / Project Guidance / Re: Servo controlled with a Pot. Approach 2? on: August 18, 2012, 08:47:02 am
That's not like a car.

Good point. In a conventional car, the position of the steering follows the position of the control. Trying to steer a car by controlling the speed of the steering wheel movement would be a nightmare.
4924  Using Arduino / Project Guidance / Re: Screwed up, hoping for help on setting a pin as ground... on: August 18, 2012, 08:45:04 am
How are those LEDs connected to the Arduino? How much current do they take in total? While you can drive one LED directly fairly safely, it's very easy to overload the Arduino output by trying to drive too many - the maximum safe current is only 20mA per pin.
4925  Using Arduino / Project Guidance / Re: Sim racing handbrake with potentiometer and Arduino Uno on: August 18, 2012, 08:42:24 am
Is this for a PC game? Why not just use one axis of a plain old USB joystick?
4926  Using Arduino / Project Guidance / Re: Mechanical indicator on: August 18, 2012, 08:41:29 am
I can't use an LED because LEDs are not low-power.

It's possible to get very small LEDs that don't use much power. How much energy they use would depend how long you left them on after your time had elapsed.

I suppose that an LCD would use less power. Watches routinely run them for years on a small battery. I've no idea how to drive an LCD display but I imagine you could find out.
4927  Using Arduino / Project Guidance / Re: time counter on: August 18, 2012, 08:37:25 am
I would use something like this :

Code:
unsigned long lastSecond = 0;
int seconds = 0;
int minutes = 0;
int hours = 0;

if(millis() - lastSecond >= 1000)
{
    lastSecond += 1000;
    seconds++;
}
if(seconds > 59)
{
    seconds = 0;
    minutes++;
}
if(minutes > 59)
{
    minutes = 0;
    hours++;
}
4928  Using Arduino / Project Guidance / Re: home automation door switch timer problem on: August 18, 2012, 08:33:20 am
You're using lightstate to detect changes in the door position but that doesn't work because lightstate doesn't reflect the previous state of the door.

I suggest you detect door changes by explicitly comparing the current state of the door sensor with the previous state.

If the door is opening, turn the light on.

If the door is closing, note the time that the door closed and leave the light on.

If the light is on and the door is closed, compare the current time with the time the door closed to see whether it is time to turn the light off.

Your state variables will be:

A flag recording whether the light is on.
A flag recording whether the door is currently open.
The time at which the door was closed.
4929  Using Arduino / Project Guidance / Re: Control bipolar stepper motor with potentiometer? on: August 18, 2012, 08:25:54 am
Code:
  digitalWrite(COIL1,LOW);
  digitalWrite(COIL2,LOW);
  digitalWrite(COIL3,LOW);
  digitalWrite(COIL4,LOW);

Are you powering down your stepper as soon as you think it is in the right place? Why are you doing that?
4930  Using Arduino / Programming Questions / Re: Understanding milliseconds in a script from a friend. on: August 17, 2012, 05:16:36 pm
That is an atrocious coding style which obfuscates the control structure of the code. No wonder you're having trouble figuring out how often each piece of code is called. Tom Carpenter's version is a vast improvement. I recommend you follow Tom's style in future but with one small change - don't put the opening brace on the same line as the function signature. Use this:

Code:
void loop ()
{
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1)
  {
    ...

instead of this:

Code:
void loop (){
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1)
  {
    ...
4931  Using Arduino / Project Guidance / Re: Arduino and Virtual Server on: August 17, 2012, 04:57:14 pm
can anyone tell me how can i do it??

Sounds like you want your PC to receive events from the Arduino and provide it with some data stored somehow on the PC. In principle that's straight forward to do and there are various ways you could do it. Ultimately you have an application running on the PC which reads messages from the Arduino's serial port, does whatever storage/lookup you want and then writes the reply back to the serial port. But there are lots of ways to implement the application, and which is best for you will depend on what you want it to do, and what programming skills and experience you have.

Quite why you want to have your application running in a VM escapes me, but that would be feasible as long as the physical PC's USB port was available to the VM. Some VM hosts enable you to map the USB ports through. If your preferred one doesn't then there are freeware solutions which can be used to tunnel a serial port over a network connection and you could use that to bring the Arduino's serial port into the VM. The overall solution is looking a bit tortuous, but none of the steps involved are especially complicated.
4932  Using Arduino / Programming Questions / Re: Arduino speedometer not working for an unknown reason on: August 16, 2012, 09:43:32 pm
Code:
if (217/duration*3.6 == -0 || -10 || -20 || -30) {

This is utter nonsense, as has already been explained.
4933  Using Arduino / Programming Questions / Re: Questions combining RTC sketch to turn motor sketch on/off 2x daily on: August 16, 2012, 08:38:00 pm
Have a global variable that records the RTC time when the motor was last turned on.

Write some code that reads the current time from the RTC and works out whether 12 hours have elapsed since the motor was last turned on. If it has, turn the motor on and record the new time.

Write some code that reads the current time from the RTC and works out whether 30 minutes has elapsed since the motor was turned on. If it has, turn the motor off.

Put the two bits of code described above in your loop() function so that they will get called repeatedly.
4934  Using Arduino / Programming Questions / Re: How to use class-specific variables in a function? on: August 16, 2012, 08:30:11 pm
Specifically if I define an int or bool in the public or private how do I write to it in a method? What would I write?

That part is easy and has been explained at least twice in this thread. But what you were trying to do in your original post seemed to be access a 'struct array' and it was unclear whether this was a struct, an array, a struct with an array in it, an array of structs, or what. Of course the syntax for dealing with that depends entirely on what your data structure is - and your code didn't include that.
4935  Using Arduino / Project Guidance / Re: Servo controlled with a Pot. Approach 2? on: August 16, 2012, 05:27:12 pm
I assume you have a normal servo where you control the position.

You want your pot to control the servo's speed. The simplest way is to process the position of the pot at regular intervals. Each time, you measure the position of the pot, calculate the deflection away from the neutral position, calculate the servo speed associated with that deflection and add a corresponding amount to the servo position.

The relationship between pot position and servo speed doesn't have to be linear - you can arrange for it to have a deadband around the 'at rest' position and you can control how quickly the speed increases as you move away from there.

Actually, I lied. The simplest approach is to replace your standard servo with a continuous rotation servo and then you can get the effect you wanted without changing the sketch at all.
Pages: 1 ... 327 328 [329] 330 331 ... 454