Show Posts
Pages: 1 ... 8 9 [10] 11 12 ... 269
136  Using Arduino / Programming Questions / Re: Help Needed!! Controling Servo Angle Trhough Xbee on: June 24, 2014, 01:09:08 am
Code:
case '1':
  case 1:
You still don't quite get it, do you ?
137  Using Arduino / Programming Questions / Re: Count Boolean Elements on: June 23, 2014, 12:23:39 pm
Is there no way to simplify it?

Yeah, use an array.

That's what I was trying to do initially but I'm not sure how to proceed,
What I posted above is pretty close to what I'm expecting but it doesn't work.  smiley-fat
Look at the suggestion that I posted earlier in this thread that uses an array.
In the example the array was declared and checked in setup() but you could set the array elements anywhere in your program and turn the code that checks it into a function.  Don't take my example too literally.  I was not trying to write your code for you but aimed to give you the tools to do it yourself.
138  Using Arduino / Programming Questions / Re: Count Boolean Elements on: June 23, 2014, 11:02:38 am
Quote
So I have a boolean that contains several elements like so:
Actually you have 5 booleans not one. 

You could use an array like this
Code:
boolean box[] = {true, true, false, true, true};

void setup()
{
  Serial.begin(115200);
  byte counter = 0;
  for (int i = 0; i < 5; i++)
  {
    if (box[i])
    {
      counter++;
    }
  }
  if (counter > 3)
  {
    Serial.println("Yup");
  }
  else
  {
    Serial.println("Nope");
  }
}

void loop()
{
}
139  Using Arduino / Programming Questions / Re: Serial Monitor Issues on: June 23, 2014, 02:20:23 am
Which pin is the pot wired to and how ?
I have a sneaking suspicion that you have it wired to pin 0 instead of pin A0
140  Using Arduino / Programming Questions / Re: Code not working, why? on: June 22, 2014, 03:07:20 pm
Quote
Can I do like this ?
If you want to, but wouldn't it be better to get your current program working first ?
141  Using Arduino / Programming Questions / Re: Code not working, why? on: June 22, 2014, 08:50:29 am
Quote
The 1st loop turns on the leds and 2nd loop turns off.
Leaving aside any other problems for the moment, how long will the LEDs stay on so that you can see them ?
142  Using Arduino / Programming Questions / Re: Code not working, why? on: June 22, 2014, 08:12:00 am
Quote
it is not working.
What does it do or not do ?

Code:
  for (int thisLed = 0; thisLed < ledCnt; thisLed++) {
    digitalWrite(ledPins[thisLed], HIGH);  // Turn on LED
  }
  for (int thisLed = 9; thisLed > (ledCnt - 1); thisLed--) {
    digitalWrite(ledPins[thisLed], LOW);  // Turn on LED
  }
Which of the digitalWrite() commands turns the LED on and which turns it off ?  If the second one turns them off then you will have no time to see them on.  Shouldn't you turn off all of the LEDs before turning some of them on ?

Code:
    digitalWrite(ledPins[thisLed], LOW);  // Turn on LED
The first time through the for loop you will be reading the 10th element of the 9 element ledPins array.
143  Using Arduino / Programming Questions / Re: Help Needed!! Controling Servo Angle Trhough Xbee on: June 22, 2014, 08:09:56 am
After
Code:
    data = Serial.read();
have you tried printing data to see what you are actually getting ?

How about some Serial.prints so that you know which portions of code are being executed ?
What have you got the line ending set to in the Serial monitor ?

The transmitter sends "1" or "0" but in the receiver you check for an int value of 1 or 0.  Are they ever going to be equal I wonder ......
144  Using Arduino / Programming Questions / Re: I need help developing a new program. on: June 22, 2014, 07:52:41 am
Quote
no, I didn't mean to have a main() function.
Then I am intrigued as to why it was there.  As has been suggested you should look at some of the examples to see how an Arduino 'sketch' (horrible word !) is constructed.  You can have a main() function if you want but it is normally added invisibly behind the scenes when compiling from the IDE.
145  Using Arduino / Programming Questions / Re: MIDI doesnt work when I add buttons on: June 22, 2014, 06:35:39 am
How are the input buttons wired ?  Are you using any pulldown resistors so that when a button is not pressed the input voltage is not floating and possibly causing spurious inputs ?
146  Using Arduino / Programming Questions / Re: choice- if/else-switchcase-while etc for Photo Booth trigger and countdown on: June 22, 2014, 05:17:02 am
Well, it is not unknown for thread titles to be misleading.....
In this case the solution could at least use one of the methods mentioned.

Code:
if (theButtonIsPressed)
  {
    //do stuff
  }
else
  {
     //do something else
  {

Code:
switch (buttonState)
  {
    case pressed:
    //do stuff
    break;

    default:
     //do something else
    }
147  Using Arduino / Programming Questions / Re: choice- if/else-switchcase-while etc for Photo Booth trigger and countdown on: June 22, 2014, 02:33:31 am
Quote
from my research I think I need to have some if/else code to make this work, but the fact that my moment switch will only be closed for a second could be an issue or maybe the  switch case/break option could work. I really am very new to this and have hit a wall as all my attempts have failed, can anyone point me in the right direction?
You need to code your program such that it reacts to the change from the switch not being pressed to it being pressed and take actions when that happens, rather than acting while the switch is pressed.  See the StateChangeDetection example in the IDE. 

You should also probably incorporate a delay after the picture is taken to prevent multiple pictures being taken if someone stabs at the button several times either accidentally or on purpose. 

The delay() function stops anything else happening until the delay is over which is bad news if you want to do timing whilst other events are taking place or inputs need to be reacted to during the delay.  There are techniques to avoid this problem but in your case it looks like all events are linear and it will not cause a problem.
148  Using Arduino / Programming Questions / Re: Communication between a Gyro and Arduino on: June 21, 2014, 03:19:36 pm
Quote
How would I go about going in and seeing the statements inside this function?
They are both in the code you posted......
149  Using Arduino / Programming Questions / Re: concatenation of non constant character array with a sting on: June 21, 2014, 03:09:23 pm
Quote
I read this page on string concatenation. http://arduino.cc/en/Tutorial/StringAdditionOperator
Did you notice that it refers to Strings not strings by any chance ?
150  Using Arduino / Programming Questions / Re: Help about an asservissement on: June 20, 2014, 04:33:15 pm
// this is a comment
/ /  this is not a comment
Pages: 1 ... 8 9 [10] 11 12 ... 269