Loading...
  Show Posts
Pages: 1 ... 33 34 [35] 36 37 ... 93
511  Using Arduino / Programming Questions / Re: problem on Analog read on Piezo sensors for triggering + timelapse on: March 28, 2013, 05:39:51 pm
Quote
I really need just 1 noteOn and not 3 in a row !
Is there a line of code to get ride of the others ?
Not a line of code but you can do it with several
Once you have detected a hit set a flag and clear it after a time which you will have to determine, but about 50ms would be a starting point.  Whilst the flag is set ignore other positive reads from the device.
512  Using Arduino / Programming Questions / Re: My latest project on: March 28, 2013, 05:31:27 pm
Code:
  if (line_status = 1)
Not what you meant to type, I suspect.
513  Using Arduino / Programming Questions / Re: Dumb Question - Global variable not holding value on change on: March 28, 2013, 05:06:14 pm
Quote
This is not correct function as I understand it a global variable should maintain it's value until the loop restarts
It would be more accurate to say that it retains its value until something changes it.  loop() restarting has nothing to do with it.
So, eXtime is not declared global after all and is behaving as one would expect considering that it is declared and initialised as the first thing in loop()
514  Using Arduino / Programming Questions / Re: cbutton help please. on: March 28, 2013, 04:12:56 pm
Can you please give a link to CButton.h and post any code that you have written so far ?
515  Using Arduino / Programming Questions / Re: Run a function by calling a variable? (or something similar) on: March 28, 2013, 04:10:36 pm
Your program is never going to exit the getButton() function as far as I can see because the while(true) condition will, by definition,  always be true.  In any case, why not cascade the cases and set the gotButton and button variables once.  There is no need to set button = serialread you might just as well set button = Serial.read() in the first place.

None of this answers your question, of course !
516  Using Arduino / Programming Questions / Re: Dumb Question - Global variable not holding value on change on: March 28, 2013, 03:55:05 pm
Quote
This is not correct function as I understand it a global variable should maintain it's value until the loop restarts
It would be more accurate to say that it retains its value until something changes it.  loop() restarting has nothing to do with it.

To get more help you must post all of your code or attach it to a post.
517  Using Arduino / Programming Questions / Re: Question on attachInterrupt function? on: March 28, 2013, 11:18:22 am
Quote
if I push that button attached to interrupt pin 0 again during the function being ran by the interrupt, will it interrupt and restart the function?
No.  
Interrupts are automatically disabled when an ISR is run.  In any case an ISR should be as short as possible so reading pins is not the sort of thing that you want to do.  More likely you will set a flag or change a variable to indicate that the ISR has been triggered and respond to the flag/change in the main routine.
518  Using Arduino / Programming Questions / Re: Toggle LED with Switch (off same Adruino PIN) on: March 28, 2013, 10:05:13 am
You can certainly change the pinMode in loop() or another function.

I would be interested in knowing the details of your project assignment.  Unless it specifically tells you to use the same pin as an input and an output you may not have chosen the optimal solution to the assignment.
519  Using Arduino / Programming Questions / Re: Community Outreach Project. on: March 28, 2013, 10:01:17 am
How tiny does it need to be ?

http://www.amazon.co.uk/Tactile-Push-Button-Switch-Latching/dp/B008DS0BT6
http://ecx.images-amazon.com/images/I/41DOpxX9%2BaL._AA300_.jpg
520  Using Arduino / Programming Questions / Re: Toggle LED with Switch (off same Adruino PIN) on: March 28, 2013, 09:53:56 am
Welcome to the forum

As Jimbo says, it is not normal to use a pin as an input and an output.  Is there a particular reason why you chose to do it this way ?
How have you got the switch and LED wired ?

Please post your code here, but before doing so read the advice in the sticky posts at the start of this forum page, particularly in respect of using code tags when posting the code.
521  Using Arduino / Programming Questions / Re: unexpected results possibly from vibration on: March 28, 2013, 02:49:59 am
Cars and bikes are notoriously 'noisy' electrical environments which can affect electronic equipment attached to them.  You could try running the Arduino on a separate power supply but my best advice would be to abandon the project on safety grounds.  You are not in a position to safely test your cruise control without being a hazard to yourself or others and the thought of
Quote
they release on their own, at various different times or durations.
is very worrying.  What if the system made non commanded throttle increases in the same way ? 

I don't know where you live but it is quite possible that using such a system on public roads would be illegal without proper testing and certification.
522  Using Arduino / Programming Questions / Re: save potentiometer values in array on: March 28, 2013, 02:33:58 am
Code:
  savecolor;
  displaycolors;
  potfun;
Do you see any other functions in your program called like this ?
No
Code:
pinMode(fadeon, INPUT);
digitalRead(fadeon);
analogWrite(red, rpotval);
Notice that all the function calls have brackets after the function names.  This allows you to pass parameters to a function so that it can use them to make decisions such as which pin to set the mode for and what value the mode should be set to.  The brackets are mandatory and if you don't want to pass any parameters to a function you must still use the brackets like this
Code:
savecolor();

Once you have managed to call savecolor() you will find that it does not work because of other things being wrong (see below) but at least get your code working to call the functions.  You can prove that the functions are being called by putting Serial.print statements in then like this
Code:
int savecolor()
{
  Serial.println("In savecolor");
  fadeChooseState = digitalRead(fadeon);

  if (fadeChooseState != lastFadeChooseState)
If you don't see the messages then the function has not been called.

You have code in savecolor()
Code:
  return place[fadeChooseCounter][0] = analogRead(rpot);
  return place[fadeChooseCounter][1] = analogRead(gpot);
  return place[fadeChooseCounter][2] = analogRead(bpot);
The function will end and go back to where it was called from when it finds the first return command.  In general you cannot return more than one value from a function but do you need to ?  The place array is defined as a global variable and is accessible by all parts of your program.
523  Using Arduino / Programming Questions / Re: save potentiometer values in array on: March 27, 2013, 05:36:31 pm
You are still not calling the savecolor() function.
If the fadechoose button is supposed to save the values then read it and if is pressed call the function.  At the moment your code reads the button inside a function that is never called so the button will never be read anyway.
524  Using Arduino / Programming Questions / Re: Using an intentional infinite loop as a failsafe on: March 27, 2013, 05:11:46 pm
But where's the fun in that ?
525  Using Arduino / Programming Questions / Re: save potentiometer values in array on: March 27, 2013, 05:10:43 pm
Call it just like you do with all the other functions used by your program such a analogRead(), pinMode() and crossfade()
Pages: 1 ... 33 34 [35] 36 37 ... 93