Show Posts
Pages: 1 [2] 3 4 ... 24
16  Using Arduino / Programming Questions / Re: Programming Style on: March 02, 2013, 09:34:14 pm
@OP

I too don't care for Egyptian Style.  #3: http://www.codinghorror.com/blog/2012/07/new-programming-jargon.html

K&R for me...
17  Using Arduino / Programming Questions / Re: Delays and unsigned long on: March 02, 2013, 11:30:30 am
@Jim_Socks

Looks great!  It's really coming along!

How are you going to do the sensors for the glasses on your "carousel"?

Cheers,
John
18  Using Arduino / Programming Questions / Re: How to show only $GPGGA sentence in GPS using Arduino mcu? on: March 01, 2013, 10:08:42 am
sure?
No.
19  Using Arduino / Programming Questions / Re: How to show only $GPGGA sentence in GPS using Arduino mcu? on: March 01, 2013, 09:08:56 am
hmmm if
Serial.print("$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"); //can turn on only the second sentence (GPRMC)

Serial.print("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"); //can turn on GPRMC and GGA

how bout turn only GGA?

Serial.print("$PMTK314,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"); //can turn on GGA?
20  Using Arduino / Programming Questions / Re: Setup function not running due to initialized class? on: February 28, 2013, 09:45:32 pm
I guess I dont understand what is nonsense about it?
Im sorry I just tinker, I am not a programmer by any means.

They're trying to tell you that in your constructor you are wanting to set the values of your instance ("member") variables, yet you are creating local ("function") variables which are "hiding" the instance variables.

You have:
Code:
Artnet2::Artnet2()
{
bool matchArtnet = true;    // set values of "new" local variables
char _artnetHeader[] = "Art-Net";
int _channel_position = 1;
int _number_of_channels = 512;
// discard the above local variables
// and the instance variables are unaffected
}
But you want:
Code:
Artnet2::Artnet2()
{
matchArtnet = true;      // set values of existing instance variables
_artnetHeader[] = "Art-Net";
_channel_position = 1;
_number_of_channels = 512;
}

HTH,
John
21  Using Arduino / Programming Questions / Re: Esplora setup loop problem? on: February 28, 2013, 09:33:12 pm
I'm trying to write code that lets me use Esplora board to control a robot. When I start the code, it is supposed to set up the servos to center position but nothing happens until I press the joystick button. How can I fix the problem?

Code:
   robotstand01; < nothing happens here
...
    robotstand01(); < it works.

Seriously?
22  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?
23  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.

24  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
25  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
26  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
27  Using Arduino / Programming Questions / Re: openpipe with fluxamasynth on: February 17, 2013, 06:52:00 pm
think it will work?

Maybe!
28  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
29  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.
30  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
Pages: 1 [2] 3 4 ... 24