Show Posts
Pages: [1] 2 3 ... 232
1  Using Arduino / Programming Questions / Re: Problem: UDP Wraped with If Statement on: Today at 04:28:05 pm
What do you mean by 'stops working' ?
What do you see if you print the value of e just after the test of the value of v1 inside the for loop, and before the if after the for loop ?

Note that e will always be 1 if the 16th reading of v1 is zero no matter what the previous 15 readings were.  Is that what you intended ?
2  Using Arduino / Programming Questions / Re: LED fading with for loop on: Today at 04:16:12 pm
Code:
while(1){
  for(a=0;a<=255;a=a+10);
  for(a=255;a>=0;a=a-10);
  }
This while loop never ends and even if it did all the for loops do is to make a go from 0 to 255 then back down to zero again over and over again.  The value of a is never even used as the while loop never ends.

There is no need for a while loop because the loop() function repeats anyway as the comment says.  Take it out along with one of the for loops, change the order of the code and remove the semi-colon from the end of the for loop line, tidy up the code to make it easier to read and you get
Code:
void loop() 
{
  for(a = 255; a >= 0; a = a - 10)
  {
     // set the brightness of pin 9:
     analogWrite(9, a);   
    // wait for 30 milliseconds to see the dimming effect   
    delay(30);                           
  }
}
3  Using Arduino / Programming Questions / Re: Expected Initializer before 'int' Error on: Today at 12:35:11 pm
Nothing much wrong then ........
4  Using Arduino / Programming Questions / Re: Is a while loop embedded in if/else if legal? on: Today at 12:34:13 pm
It is 'legal' but this while loop
Code:
  while (lastColor_8 == randNumber && lastColor_2 == randNumber)  //BINARY 8 & 2
    {
   randNumber = random(11);  // Generate a new (color) randNumber
    }
will do nothing unless lastColor_8 and lastColor_2 both happen to equal the already existing value of randNumber when it starts, and even then it will end almost immediately because the condition will become false in most cases straight away.

Can you explain what it is supposed to do and how ?
5  Using Arduino / Programming Questions / Re: Expected Initializer before 'int' Error on: Today at 11:42:38 am
Code:
  for(int i=0; i< 3; i++);
Remove the semi-colon at the end
6  Using Arduino / Programming Questions / Re: New to arduino need some assistance on: Today at 11:31:47 am
What do you want the program to do ?
Code:
if something is true
  carry out action 1
end of if
else
  carry out action 2
end of else
What is the something that can be true or false ?
What are actions 1 and 2 ?
7  Using Arduino / Project Guidance / Re: void loop() 1 void loop() 2 on: Today at 08:47:02 am
It refers to an example program in the IDE.
The technique that it uses involves noting a start time then checking periodically to see whether a time interval has passed.  If yes then react to it, if not the go and do something else such as checking whether another timing period has elapsed.  

Unlike using the delay() function the program does not stall whilst the delay happens, so that the Arduino can appear to do 2 (or more) things at the same time.
8  Using Arduino / Programming Questions / Re: Midi Serial, Pin Selection on: Today at 07:48:59 am
Have a look at the MIDI_Bench example which comes with the library to see how to use SoftwareSerial with the library which leaves hardware serial free for other purposes.

Code:
SoftwareSerial midiSerial(2,3);
MIDI_CREATE_INSTANCE(SoftwareSerial, midiSerial, softMidi);
9  Using Arduino / Programming Questions / Re: Howe can I get a button to start a RF 433MHz transmitter to send a message? on: Today at 06:14:40 am
Do you really mean remote control or do you mean a wired switch or button ?
10  Using Arduino / Programming Questions / Re: Reading and writing to the same Arduino Pin on: Today at 06:12:04 am
Quote
What I want to do is check if the Digital pin is High and keep it high till the temperature falls below the set temperature.
Why do you need to test the state of the pin ?  You set its state so you know what it is already.   It will not go LOW unless/until your program sets it LOW.
11  Using Arduino / Programming Questions / Re: gsm SimpleWriteln not working... HELP! on: Today at 04:51:39 am
When you say it does not work what do you mean exactly ?
12  Using Arduino / Programming Questions / Re: Servo project help! on: April 17, 2014, 12:56:41 am
Or you might like to use the more obvious
Code:
pinMode(pushbutton, INPUT_PULLUP);
This ensures that the input pin is held at a known state (HIGH) at all times until pressing the button takes it LOW.  Obviously the wiring and the program logic need to match the HIGH/LOW off/on state of the button.
13  Using Arduino / Programming Questions / Re: Servo project help! on: April 16, 2014, 03:01:05 pm
Yes, it will need to be time based using delay() or the BWD technique.

Despite BWB being better to use in the long run (see below) I suggest that you use delay() at first and get the program working.  As to reaction to the button becoming pressed rather than being pressed, have a look at the StateChangeDetection example in the IDE.

BWD is better for most purposes because it uses the technique of noting a start time and then looking every now and again to see if the timing period has ended.  If it has then do the next action.  If not, then do something else such as reading another input, which you cannot do using delay() because the program stalls until the delay is over.
14  Using Arduino / Programming Questions / Re: Servo project help! on: April 16, 2014, 01:21:08 pm
The servo connection problem is nothing to do with the pins used. The servos take more current from the Arduino than is advisable so it is preferable to use an external power supply for them with a common GND to the Arduino.

This sounds like the outline of what you want to do
Code:
start of loop
  read the button pin
  if the button becomes pressed
    issue the command for move servo 1 to 45 degress
    wait for required period
    issue the command for move servo 2 to 45 degrees
  end if
  wait for 2 seconds
  issue the command for move servo 1 to the original position
  issue the command for move servo 2 to the original position
end of loop 
There are many details to sort out such as how to detect that the button has become depressed rather than being currently depressed, and how to know that the servos have reached 45 degrees.  (Actually that is not possible with normal servos so what can you do ?) 
How should you implement the waits ?  Using the delay() function, or is there a better way ?  (There is)
15  Using Arduino / Programming Questions / Re: error: expected initializer before 'void' need a second set of eyes!!! on: April 16, 2014, 11:14:43 am
It would be better to see your whole program, but in the meantime try Auto Formatting it and see what happens.

Code:
        }
    return GearCommand;
}
Which one of these braces ends the function ?
Pages: [1] 2 3 ... 232