Show Posts
Pages: 1 ... 78 79 [80] 81 82 ... 231
1186  Using Arduino / Programming Questions / Re: Can arduino store sets of instructions? on: November 25, 2013, 05:16:09 am
Do some research on arrays.
Read each input, put it into an array level, increment the array index, then, when input is complete read the array level by level and pass the saved commands to the motors in the same order that they were received.

You could save the commands in EEPROM but it can only be used for a fairly limited number of write cycles.
1187  Using Arduino / Programming Questions / Re: Trying to simulate a SMBus from an Smart Battery accu pack with the Arduino Uno on: November 25, 2013, 05:11:41 am
The first piece of advice that you will get from most experienced members of this forum is to stop using Strings and use C style strings instead.  What Arduino board are you using ?

What do you see if you print the String and adress when stringComplete is true ?

Actually, the code does not verify because of this line
Code:
  Wire.onReceive(receiveEvent);nt
but I assume that is as artefact of how you copied the code to the post.
1188  Using Arduino / Programming Questions / Re: Serial RX getting stuck on: November 24, 2013, 05:12:12 pm
Quote
is there a way for the Arduino to know that there is no more data coming in to RX without having to Serial.read() the whole input buffer?
Serial.available() is the closest that you are going to get I suspect, although it does not do exactly what you say you want.  What would a method telling you that no data had arrived, presumably for a defined period of time, give you that Serial.available() doesn't ?
1189  Using Arduino / Programming Questions / Re: pins_arduino.h challege - sample code anyone? on: November 24, 2013, 04:07:47 pm
Quote
struggling with usage of "pins_arduino.h
In what sense do you want to use it ?
1190  Using Arduino / Programming Questions / Re: simple LED chaser without delay on: November 24, 2013, 09:46:29 am
It should be installed in a folder named SM under the libraries folder in the place where your programs are normally stored.  Stop and restart the IDE after you install the library.  You can check that it is available from the IDE by doing Sketch/Import Library
1191  Using Arduino / Programming Questions / Re: Help writing a simple program to use with a gear shifter for racing games on: November 24, 2013, 09:42:18 am
Lots of variables with the same name and a number on the end almost always indicates that an array could/should be used to make the code simpler.  Why use 8 variables when an array with 8 levels and a for loop could have been used ?  Something like this perhaps.
Code:
for (int button = 1; button < 9; button++)
{
  if (buttonState[button] == HIGH)
  { 
    if (gearnumber >  button)
    {
      geardown = gearnumber - button;
      geardownchanger(geardown, button);
    }
  }
}
You will need to adapt this for your own requirements but I am sure that you can see the principle.
1192  Using Arduino / Programming Questions / Re: My first Arduino Project: Monitoring and controlling Smoke Detectors on: November 24, 2013, 09:29:04 am
Because interrupt routines are meant to be short and sharp they are often used simply to update a variable indicating that the interrupt has taken place and the change of variable value is acted upon in loop() anyway.
1193  Using Arduino / Programming Questions / Re: My first Arduino Project: Monitoring and controlling Smoke Detectors on: November 24, 2013, 08:48:09 am
Interrupts are for events that must be acted on NOW
In practice, if you use millis() and detect the alarm in loop() it may take a few milliseconds longer to react but will that matter in practice ?
1194  Using Arduino / Programming Questions / Re: My first Arduino Project: Monitoring and controlling Smoke Detectors on: November 24, 2013, 07:57:02 am
Code:
    delay(540000); // Maintenance LED for 9 Minutes ON
OUCH !
You are totally wasting the Arduino during this 9 minute delay.  Ditch the delays, use millis() for timing and get rid of the interrupts too as you will be able to monitor button inputs in the loop() function.
1195  Using Arduino / Programming Questions / Re: Smoothing analog input for MIDI continuous controller messages on: November 24, 2013, 06:05:52 am
Put the Serial.print inside the for loop so that it prints the val of the current sensor
Code:
if (abs(val - oldVal[i]) > threshold)
{
    Serial.println(val);
 }
1196  Using Arduino / Programming Questions / Re: Aircraft Balancing on: November 24, 2013, 05:48:42 am
Can you describe the erratic movements ?
Does it move in the correct direction but in uneven jumps instead of smoothly ?

As your servo is currently only moved in the Balance() function and nothing else happens in that function my suspicion would still be that the problem is related to the power supply to the servo.  Exactly how have you got the servo and Arduino wired and what sort of external power supply are you using for the servo ?
1197  Using Arduino / Programming Questions / Re: Unable to pad zeros on Speedometer code. on: November 24, 2013, 03:23:34 am
Consider using sprintf to build the string to be output.
Code:
int KMPH;
char buffer[4];

void setup()
{
  Serial.begin(115200);
  KMPH = 97;
  sprintf(buffer, "%03d", KMPH);
  Serial.println(buffer);

  KMPH = 0;
  sprintf(buffer, "%03d", KMPH);
  Serial.println(buffer);
}

void loop()
{
}


1198  Using Arduino / Programming Questions / Re: Aircraft Balancing on: November 24, 2013, 03:06:11 am
Quote
can anyone see why im having this prob ?
How is the servo powered ?  Directly from the Arduino or from an external source with a common GND ?  Of the former, then it is probably drawing more current that the on borad voltage regulator can supply.
1199  Using Arduino / Programming Questions / Re: Difficulty with serial programming (not sure where to continue) on: November 23, 2013, 05:16:33 pm
You currently have no commands to read any buttons in the code that you posted.  You need to read the value of the two pins before you can do anything with them.  What you send when you find one, or both, pressed is up to you.  How about sending -1 for reverse, 0 for no input or 1 for forward ?  The code at the receiving end will, of course, need to be able to read the data, interpret it and act on it appropriately.

Please post both sets of code so that more help can be given.
1200  Using Arduino / Programming Questions / Re: Running part of the loop only once on: November 23, 2013, 12:32:00 pm
Code:
    if ( ch == '\n' ) {
This is not a criticism of the code, but note that this is a check for a newline character at the end of the serial input, so that the line-ending parameter must be set accordingly in the Serial monitor or other terminal device used.
Pages: 1 ... 78 79 [80] 81 82 ... 231