Show Posts
Pages: 1 [2] 3 4 ... 24
16  Using Arduino / Programming Questions / Re: USB-Weather-v31 errors on: February 28, 2013, 11:57:37 am
Did you copy the folders SFE_BMP085 and SHT1x into your libraries folder?
17  Using Arduino / Programming Questions / Re: Print a byte using streaming on: February 26, 2013, 08:32:45 pm
Quote
I didn't find the answer at the arduiniana site.
You didn't see the _HEX() and _BYTE() macros being used?

Yes, but since their snippet showed neither the variable types nor the output it produced, I didn't draw the conclusion that _BYTE() would do what he wants--basically the same as char().  Though apparently that is the case, thanks.

18  Using Arduino / Programming Questions / Re: Print a byte using streaming on: February 26, 2013, 07:19:01 pm
I didn't find the answer at the arduiniana site.

@gharryh, I think this will work:

char deg(176);

Cheers,
John
19  Using Arduino / Programming Questions / Re: Turning on random LEDs using a pushbutton. on: February 26, 2013, 07:04:48 pm
The issue is not so much debounce as it is also one of state-change.  I think if you hold your on-button down all three leds will eventually light (which is probably not what you want according to your original statement of requirements).  If you agree, the fix is  to turn on a random led only once when the button goes from off to on ( rather than every time through the loop when the button is on).

Cheers,
John
20  Using Arduino / Programming Questions / Re: Passing I/O functions to a class. on: February 23, 2013, 08:20:22 am
@OutOfLine

Not sure where in this thread it fits, but on the Arduino I usually use the Streaming Library, like this:
Code:
#include <Streaming>
...
Serial << "Hello there " << ", i= " << i << endl;
...

And then when I compile for various reasons on another platform I use:
Code:
#include <iostream>
using namespace std;
ostream & Serial = cout;

... so now I can use throughout, the same

Serial << "Hello there " << ", i= " << i << endl;

Cheers,
John
21  Using Arduino / Programming Questions / Re: openpipe with fluxamasynth on: February 17, 2013, 06:52:00 pm
think it will work?

Maybe!
22  Using Arduino / Programming Questions / Re: Reading and writing to a single digital pin on: February 17, 2013, 06:41:03 pm
@OOO

I think your approach is interesting and am looking forward to seeing it work.

You need to avoid reading the button/led that you have already turned on.

Maybe something like this (compiled but not tested)
Code:
/*
    "Radio Buttons"
    When a button is pressed, latch its own LED on, and turn all the others off
*/
const int nButtons=3;
int buttons[]= { 7, 12, 14 };  // each "button" is a button/led pair
int currentOn = 0;

void latch( int onPin)
{
    // turn onPin on,
    digitalWrite( onPin, LOW);
    pinMode( onPin, OUTPUT);

    // if there is an other pin on, turn it off
    if (currentOn > 0)
    {
       pinMode( currentOn, INPUT);
       digitalWrite( currentOn, HIGH);  // pullup
    }
}

void loop()
{
  for (int i=0; i< nButtons; i++)
  {  
      // read all but the currenly-on button
      if ( buttons[i] != currentOn && digitalRead( buttons[i])== LOW)  // active LOW
      {
          latch( buttons[i]);
          currentOn = buttons[i];
          break;
      }
  }
}

Cheers,
John
23  Using Arduino / Programming Questions / Re: Reading and writing to a single digital pin on: February 17, 2013, 06:21:05 pm
Yes, good point.  He should avoid  reading the one that has already been latched on-- and only read the other ones.  That is the problem with his current code.
24  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
25  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);
}
26  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?
27  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
28  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
  
29  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
30  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

Pages: 1 [2] 3 4 ... 24