Show Posts
Pages: 1 ... 35 36 [37] 38 39 ... 85
541  Using Arduino / LEDs and Multiplexing / Re: I'm stuck in ledControl and a Max7219 board. (Partly solved) on: June 05, 2013, 04:47:12 pm
Just to try something different, instead of setting the boolea, set the characetr to be displayed in a char variable and then use that char in the display? I can't see it either but sometimes just changin what you are doing can shed light on the problem.

    if (v<0)
        c = '-';
        v = -v;
    c = ' ';


       lc.setChar(0, 4, c, false);
542  Using Arduino / Displays / Re: 2 line LCD display: can't figure out pinout on: June 05, 2013, 07:12:37 am
If you have the pin definitions, look for the ground pin and try and find it among the pins. Ground is usually connected to the ground plane and is easy to find.  Once you have that the rest should fall out easily enough.
543  Using Arduino / LEDs and Multiplexing / Re: I'm stuck in ledControl and a Max7219 board. (Partly solved) on: June 05, 2013, 07:01:45 am
Then negative must be set wrong. Try printing it out in a few places?

There is not much to this program, so print things as you go through and see where things don't make sense.
544  Using Arduino / LEDs and Multiplexing / Re: I'm stuck in ledControl and a Max7219 board. How to input numbers? on: June 03, 2013, 09:27:57 pm
Use Serial.print() to see what the value v is. If it is not negative (and it should not be) then the fault is in your logic for how you determine and/or print '-'.

Serial.print() is your friend in this sort of debugging.
545  Using Arduino / LEDs and Multiplexing / Re: I'm stuck in ledControl and a Max7219 board. How to input numbers? on: June 02, 2013, 08:10:47 pm
It would help if you tell us what the compile error is, and you put the actual code that is causing the error in the post. The current code does not appear to have any way of inputting the number, unless I am missing something.
546  Using Arduino / Storage / Re: Read SD card for data on: June 02, 2013, 07:05:12 pm
Have you done any tests to see if it is possible to read the amount of data in the time you are expecting?

A simple loop with timing values (I guess microsecond rather than millis) either side of the 'read' will give you some base data to look at to decide feasibility of the approach.
547  Using Arduino / Programming Questions / Re: changing calculating time depending on speed of readings on: June 01, 2013, 08:18:57 pm
A flag is usually a normal Boolean (true/false) variable that is used to indicate an event has happen or a condition has been reached.

The event 'sets' the flag so that it is seen by other parts of the code and can be 'reset' when the event is processed. Think of the US postal service setting the 'flag' on a letterbox so that you don't need to walk out to the letterbox to check but just need to see, from a distance, check if the flag is set.

Most useful to capture one-off events (like an interrupt), or to create a proxy for a complex checking sequence (like walking out to the letterbox).
548  Using Arduino / Programming Questions / Re: Exiting an "if" statement on: May 31, 2013, 03:17:56 pm
If you are rewriting code, then consider using a function for this block of code which is repeated many times:


setMotors(FORWARD, 200, FORWARD, 200, 100);

if you define a function
void setMotors(uint8_t dirM1, uint16_t spdM1, uint8_t dirM2, uint16_t spdM2, uint16_t waitDelay)

I would also say that at some point you will need to get rid of the delays in you code for this software to run properly. Look at the Blinkwithoutdelay example in the IDE for how you can do this.
549  Using Arduino / Programming Questions / Re: Exiting an "if" statement on: May 30, 2013, 09:48:55 pm
if ( 10 >= distance >= 1)

I can remember making this mistake when I wrote my first BASIC programs, way back when a TRS80 was high tech, because this is the mathematical representation of the intent. In code you write each comparison is a single comparison between values.

if ((10 >= distance ) && (distance >= 1))

or, as a style thing,

if ((distance >= 1) && (distance <= 10))

550  Using Arduino / Programming Questions / Re: Rounding sensor values down to 2 decimal places on: May 30, 2013, 09:40:15 pm
One (convoluted) way is to multiply by 100 (or 10^x where x is the number of decimal points you need), cast it to an int or long, then assign it back to a float and divide by 10^x.

eg, using 10.987
* 100 = 1098.7
to int 1098
to float 1098.0
/100 = 10.98

If you just need conversion when the number is printed you can specify that in the print statement.
551  Using Arduino / Storage / Re: Averaging Array on: May 30, 2013, 09:32:58 pm
If you are just looking for the average value every five minutes (ie, not a running average of the *last* five minutes), you can do that without an array.

You need 2 variables - the current average and the number of values read so far.
1. Initialise the average to the first value in the time period, set the count = 1
2. Every other value that arrives is added as follows: average = ((old_average * count) + current_value)/(count+1);
3. count = count+1

At the end of your period use the avarage, reset the counters and start again.

Running average over the last five minutes is a different story and will need some form of storage.
552  Using Arduino / Programming Questions / Re: creating function that blink led by number of my choice on: May 26, 2013, 10:19:18 pm
void blinkred( char c_Pin, char c_Count  )
void blinkred( uint8_t u_Pin, uint8_t U_Count  )
be better style?

For me it is clearer that we are dealing with an unsigned number and not a character (even if the result may be the same).
553  Using Arduino / Programming Questions / Re: |= please help! on: May 18, 2013, 12:21:31 am
A |= B is the same as A = A|B

You can use the same for all the other operators (+=, *=, /=, %=, you get the idea). It is just a shorthand, just as A++ is the same as A+=1 or A=A+1.
554  Using Arduino / Programming Questions / Re: Piezo Switch input Analog or Digital, and detection on: May 12, 2013, 02:33:39 am
The piezo generates a lot more than 2-4V. Here are some references for you to read:

This one has a comparator type output towards the end that may be what you are looing for.

More general on what happens when a piezo is pressed.
555  Using Arduino / LEDs and Multiplexing / Re: I'm lost and desperate. Need help with RGB's, 595 shifters, on: May 11, 2013, 07:12:13 am
On my site (link below in my signature) I have some sketches that drive seven segment displays using the 595 shifter.
Pages: 1 ... 35 36 [37] 38 39 ... 85