Show Posts
Pages: 1 2 [3] 4 5 ... 25
31  Using Arduino / Programming Questions / Re: Reading and writing to a single digital pin on: February 17, 2013, 02:02:47 pm
Ok, I see.  You have never said though, what does your serial output show?  Is it tracking properly with your button presses?  You might want to slow your loop down, e.g. delay(500) instead of delay(50).  Also you could put serial.prints within your if statements like "Turning 1 on", "Turning 2 on".  And maybe even a delay(250) in between the two if statements.  All together this may allow you to see what's going on.  E.g. are you sure you don't have a sticking switch, etc.

Cheers,
John

i.e. pseudocode
read both buttons
print button values
if button1
   print "Turning 1 on"
   turn 1 on, 2 off
endif
delay 250
if button2
   print "Turning 2 on"
   turn 2 on, 1 off
endif

delay 500
32  Using Arduino / Programming Questions / Re: Reading and writing to a single digital pin on: February 17, 2013, 12:09:08 pm
I believe that it will work the way you have said you want it to, if you follow PeterH's suggestions.

If it is not, check your wiring and pin assignments?  What exactly is it doing/not doing?

Code:

// "When a button is pressed, latch it's own LED on and turn off all the others"

buttonState_1 = digitalRead(button_1);
buttonState_2 = digitalRead(button_2);

if(buttonState_1 == 0)   // Button 1 is pressed. Switch shorted with ground
{
    // "turn off all the others"
    pinMode(button_2,INPUT);
    digitalWrite(button_2,HIGH); // note active LOW, so this turns led2 off
   
    // "turn my own led on"
    digitalWrite(button_1,LOW);  //  active LOW to enable led1
    pinMode(button_1, OUTPUT); // turn it on
}

if(buttonState_2 == 0)   // Button 2 is pressed. Switch shorted with ground
{
    // "turn off all the others"
    pinMode(button_1,INPUT);
    digitalWrite(button_1,HIGH);
   
    // "turn my own led on"
    digitalWrite(button_2,LOW);
    pinMode(button_2, OUTPUT);
}
33  Using Arduino / Programming Questions / Re: openpipe with fluxamasynth on: February 16, 2013, 08:18:33 pm
Are they from the library provided by moderndevice?  Then they are supposed to...

Why don't you load the example sketch that comes with the library to find out?
34  Using Arduino / Programming Questions / Re: need more a life effect... on: February 16, 2013, 09:11:23 am
@warpie,

You will find what you need to learn here: http://gammon.com.au/blink.

Especially the example(s) of fading leds.

Cheers,
John
35  Using Arduino / Programming Questions / Re: Mouse keep alive on: February 14, 2013, 01:05:41 pm
You're pretty close

Remember this?
if ( timeNow - timeStart > 14000 )
{
   Jiggle Mouse
   timeStart = timeNow
}

timeNow is your millis()  --> good
timeStart is your "wait"    --> ok
14000 is your "interval"    --> ok
Jiggle mouse is close       --> needs work, see below
timeStart=timeNow        -->  need to add this, your equivalent would be wait=millis()

To Jiggle mouse:
    Mouse.move(8,8);
    delay(25);
    Mouse.move(-8,-8);   // move it back

Mouse.begin(), Mouse.end() not needed as far as I know.

Cheers,
John
  
36  Using Arduino / Programming Questions / Re: Mouse keep alive on: February 13, 2013, 10:05:01 pm
@PeterH

Actually the "Why ask Why" I intended to refer to "... my kids just plug in the dongle rather than reconfiguring their screensaver...", sorry.

On Ubuntu 10.04 and 12.04 LTS on my hardware the screensave/powermanagment has been broken, not just misconfigured.  It has not been a big enough deal to me to warrant the linux research/patch/install cycle that would probably ensue...

It is not a breach of my company policy use my company-issued laptop for incidental personal use such as netflix/etc,  or to use such a dongle while doing so.  Anyone else should check their policies for detail, ymmv, etc...

John
37  Using Arduino / Programming Questions / Re: Mouse keep alive on: February 13, 2013, 09:33:49 pm
@Antennas

You are right that you need to use millis() something like this pseudocode, somewhere in your loop() function

if ( timeNow - timeStart > 14000 )
   Jiggle Mouse
   timeStart = timeNow

For more details see http://arduino.cc/en/Tutorial/BlinkWithoutDelay and even better is http://gammon.com.au/blink

Cheers,
John

38  Using Arduino / Programming Questions / Re: Mouse keep alive on: February 13, 2013, 09:21:32 pm
This was the very first thing I made when I got some Teensies, and it gets used routinely at our house using different laptops/netbooks plugged to the TV for netflix etc.  I just leave it by the TV.

* Some pc's the screensave/power managment settings don't work (Ubuntu)
* Some pc's they are locked out by group policy (e.g. my company laptop)
* For some of my kids they just find it easier to plug in the TV, plug in the Dongle
* Why ask why?

Cheers,
John

(Ps moving a few pixels and then back every 10 minutes does not seem to interfere with normal mouse use, even if you forget to take it out )

39  Using Arduino / Programming Questions / Re: Using other IDEs to develop on: February 13, 2013, 09:09:21 pm
I sometimes/often use Eclipse CDT and like it a lot.  It was not very hard to install and configure the http://www.baeyens.it/eclipse/ plugin.

The CDT has the native g++ toolchain with it already.  So you can often write/run/test/debug/simulate difficult parts of your code on your pc, and then copy or "link" into your Arduino project.

It's amazing how helpful are the features are like autocomplete, F3 "zoom-to-definition", ctrl-tab switch between cpp and header, etc!

Cheers,
John
40  Using Arduino / Programming Questions / Re: random void? on: February 13, 2013, 08:57:19 pm
Maybe something like this?

Code:
int pick( int a, int b)
{
   return random(2) ? a : b ;
}

void loop() {
  static int next;

  lcdscreen();

  switch (next) {
   case 0: redlight();   next= pick( 1,2);  break;
   case 1: bluelight();  next= pick( 0,2);  break;
   case 2: greenlight(); next= pick( 0,1);  break;
   }

}


if you don't want It to produce the same pseudo-random sequence each time you boot/power it-- see http://arduino.cc/en/Reference/random

Cheers,
John
41  Using Arduino / Programming Questions / Re: Error: "has not been declared" on: February 12, 2013, 12:00:07 am
Any idea about the original question though?

Quote
Any idea about the original question though?
I'd be interested in investigating further, if only you had posted ALL of your code.

I'm not the OP.

Is there a forum setting that automatically removes the author when quoted?  --Or do you do that explicitly each time you reply.
42  Using Arduino / Programming Questions / Re: moisture sensors on: February 11, 2013, 11:46:44 pm
its still flickering.....yes i run one pump and four valves , the pump and valve are suppose to turn on when the the sensor is dry..

Think about if some of the four sensors are dry and others are wet...

Your code:
The dry ones are telling the pump "turn on!"
The wet ones are telling the pump "turn off!"

If I was the pump I would probably be flickering too smiley

John
43  Using Arduino / Programming Questions / Re: Error: "has not been declared" on: February 11, 2013, 06:59:47 pm
Any idea about the original question though?
44  Using Arduino / Programming Questions / Re: openpipe with fluxamasynth on: February 11, 2013, 06:27:48 pm

should I delete this to?

the question really is, should I add any thing?


I don't think that will matter.  Also, the instrument=0 will not matter because it is not being used anywhere either.

Sorry, I don't know anything about the shield or Midi.

And, what is your thinking about the "VS1053 reset line"?

Cheers,
John
45  Using Arduino / Programming Questions / Re: openpipe with fluxamasynth on: February 11, 2013, 05:48:12 pm
Then look at every function that ends in
Code:
Serial.write(midiMsg.raw, sizeof(midiMsg));
And delete the whole of the function.

Any calls to these deleted functions should be replaced to the other set of midi out functions you have in that sketch.

None of those three errant functions are actually being called in the sketch anyway...
Pages: 1 2 [3] 4 5 ... 25