Show Posts
Pages: 1 ... 6 7 [8] 9 10 ... 91
106  International / Nederlands / Re: Hoge spanning en stroom meten on: March 14, 2014, 11:34:16 am
Wacht ff.
Een kleine 10 deler ?
Als je daarmee twee weerstandjes bedoelt, dan moet je heel goed oppassen.
Het kan best zijn dat dat wiskundig klopt.
Maar het is maar de vraag of die weerstanden zijn ontworpen om veilig de daarover vallende spanning te verwerken.
Je moet in ieder geval niet zomaar een standaard weerstandje pakken en die in een 230 volt installatie opnemen, dat kan tot grote problemen en/of gevaren leiden.
107  Using Arduino / Programming Questions / Re: Help increment/deincrement push buttons? on: March 13, 2014, 07:10:04 pm
You now solved the transition from =>100 to <100.
But you are checking to see if you are going below 100.
If you go < 10, you are also < 100 and that is why that works in that case too.
There is no need at all to do that check to see you've gone < 100.
Any time you are going to write to your LCD, you can first erase the old content of that part.

About those delays: ask yourself why those are there.
What's the purpose of the delay in line 49, 66, 79, 98  ?
I can guess why they were there in the example you got them from (debouncing), but that seems to be gone now.
If you're not sure you can dump those lines, you can simply //comment them out and see what happens.

By the way: debounce is a good thing, and you should study that a bit.
It will prevent accidental multiple increments/decrements upon a single keypress.
You could count a number of unchanged buttonStates (if it would change, the count needs to be reset) to reach this.
That will speed up your code, as the delays will be gone.

This comment isn't exactly what you are doing:
// if the state has changed, increment the counter
You only want to increment if the state goes or is HIGH, and that is actually what you are doing.
You don't also want to increment if it goes back to LOW.

108  Using Arduino / Programming Questions / Re: Help increment/deincrement push buttons? on: March 13, 2014, 05:46:15 pm
Indeed you do see that 127.
And that is because you are printing the value immediately after increasing or decreasing that value (lines 46 and 64).
Much later you're doing some more processing, which was what i was mentioning.
Perhaps you should reshuffle your code a bit so things are easier to oversee (meaning: put the prints next to each other and do the processing before you print, not halfway the printing).

Quote
how to fix if<100 from to 990
It's the same difference.
Erase (print spaces and return to the start position) immediately before you print a new value.
109  Using Arduino / Programming Questions / Re: Help increment/deincrement push buttons? on: March 13, 2014, 04:57:44 pm
Code:
    if (buttonPushCounter >= 126)
    {
      lcd.setCursor(13,0);
      lcd.print("Max");
      buttonPushCounter=126;
    }
That first line checks to see if you are at 126 or larger.
The second last line will add "Max" if you are at 126 or larger.
The last line then resets it to 126.
So you'll never see 127.

"PadCutOff:" is 10 positions, but counting starts at 0 and you'll be done printing that text at position 9.
So actually there should be a space or rather undefined character (meaning whatever is already at that position):
Code:
PadCutOff: 127MAX

It seems you didn't keep that in mind, and are writing to the 17th position of your 16 position LCD because you are planning on using exactly 16 characters.
 
110  Community / Bar Sport / Re: whats with the attitude on: March 13, 2014, 04:27:54 pm
Of course it's valid.  I believe {T}he constant is converted to a long an int.

http://stackoverflow.com/questions/7459939/what-do-single-quotes-do-in-c-when-used-on-multiple-characters

Thanks Coding Badly, i didn't know that so like every day i learned a bit again today.
The result of this would be very interesting on the display.
111  Using Arduino / Programming Questions / Re: Help increment/deincrement push buttons? on: March 13, 2014, 04:18:12 pm
Your sketch is printing a value (that is never erased), and a text directly next to it if the minimum or maximum is reached.
That text will be erased if the value isn't min or max.

So the value is printed to position 10, and a text or 3 spaces to position 13.
This would result in something like this (each line is a different situation, put in code tags to not mess up alignment):
Code:
0  OFF
1     
12   
126MAX

Is that really what you meant to do ?
And this way you aren't cleaning up the numbers you're printing.
So counting down does not display what you would expect.
You would go from 100 to 990, and 89 steps later from 100 to 900.

If you like to show correct numbers, you should erase those too before you write a new number.
And if you want to line the number up correctly (instead of always lined up to the left), you should check if you're over 9 and if you're over 99 and add a space or two accordingly (or move the cursor x extra positions).
112  Using Arduino / LEDs and Multiplexing / Re: led strobe without delays help? on: March 13, 2014, 03:29:05 pm
So that is the working code ?
Has the weekend arrived already ? smiley-wink

Instead of doing this:
Code:
if (stro1num == 1)   //first blink on
  if(curstro1Millis - prestro1Millis > stro1interval1) {digitalWrite(stro1Pin, HIGH); stro1num = 2;}

You should also be able to do this:
Code:
if (stro1num == 1) && (curstro1Millis - prestro1Millis > stro1interval1) {digitalWrite(stro1Pin, HIGH); stro1num = 2;}
That should optimize your code, because you are not doing 2 if statements, but still you are processing 2 conditions.
113  Using Arduino / LEDs and Multiplexing / Re: led strobe without delays help? on: March 13, 2014, 02:01:11 am
Read my last reply again, i made a mistake yesterday.
114  Using Arduino / Programming Questions / Re: Help increment/deincrement push buttons? on: March 13, 2014, 01:56:22 am
By setting it back to zero in case you go below zero.
There's no difference here, except for the direction you're going.

The double digits will always end with  "1" and last until you get to 10.
Do you always print 3 spaces before printing a new value ?
115  Community / Bar Sport / Re: whats with the attitude on: March 13, 2014, 01:53:18 am
Quote
without any doubt true and correct
Well, they weren't correct.
"Serial.print(' ');" is perfectly valid and does what the OP expected.
Serial.print() is set up to take all sorts of arguments, one of which is "char"
People who are going to be snippy and pick nits ought to make sure they're correct!

I disagree.
While "Serial.print(' ');" is perfectly valid indeed, "Serial.println('   ');" isn't.
The difference between yours and OP's, is that OP is sending a single character that consists of 3 spaces.
How could that be right ?
And what OPwas calling an attitude, pointing to that mistake asking what that is, isn't anything else than pointing to it and make him think over what might be wrong in there.
No need to overreact to that like he did.
116  Using Arduino / Programming Questions / Re: Help increment/deincrement push buttons? on: March 12, 2014, 07:50:38 pm
If you need to stay within some boundaries, you should program those.
After debouncing a key press, you should do what that key press is meant to do.
Immediately after that you should check to see that took you beyond your boundaries.
So something like this:
Code:
     if (buttonState5 == HIGH)
     {
      buttonPushCounter++;
      if (buttonPushCounter > 127) {        // This is new
        buttonPushCounter = 127;            // So is this
      }
      lcd.setCursor(10,0);
      lcd.print(buttonPushCounter);
     }

When printing, you should erase all characters you have printed last.
So if you go down from 100 (3 characters wide) and you print 99 without erasing the old content first, you'll end up with a 990 displayed (so not 999).
To get rid of that, you should print 3 spaces, which was what johnwasser told.
There isn't much more to it.

2 AM, bedtime is long due.
Maybe i'll have some other thoughts after some sleep.
117  Community / Bar Sport / Re: List of all the 'ranks'? on: March 12, 2014, 06:09:10 pm
Do you mean this page ?
That still seems to work OK to me and i think it's very useful.
118  Community / Bar Sport / Re: whats with the attitude on: March 12, 2014, 05:54:50 pm
Where is the attitude ?

And how about this for an attitude:
So spank me and send me to bed without dinner. What does this have to do with my question!

Why are you so hypersensitive to answers you weren't expecting, but are without any doubt true and correct (helping) answers ?
By the way, did you see the link in the page you linked to ?
And did you see there that you aren't providing a str, but a pointer to it ?
I don't know anything about that yet as i haven't been playing with that.
But you might like to have a look at it.
Back on topic now.
119  Using Arduino / LEDs and Multiplexing / Re: led strobe without delays help? on: March 12, 2014, 05:27:48 pm
OK, some progress is made, so well done.
You'll get this done before next weekend if you stay at this rate.

You have now changed blink without delay in such way you think it can handle more than 2 states: on and off for a fixed time.
This is almost true, but you are missing 2 important steps.
The first one is that you forgot to keep track of what interval number you are working on at that moment.
The second one is that you are always, in every iteration, updating previousMillis to currentMillis, you really don't want to do that.
You only should update that if some requirements are met.

Tip: Find out what these curly braces { } are about, and why some people argue about two of them being at the same line.

By the way, i would not check the smallest number first.
If you check the largest number first, if that isn't met the second largest number and so on, you don't need my first step above.
So you don't need to keep track of an interval number and you will save some memory.
Not important at the moment but this will be in future code.


Edit:
Sorry that last part is incorrect.
In this case, one found value doesn't mean the other values are not true.
So when you are looking for interval4, interval3 will trigger in case you have a value of 600.
That would prevent you from ever reaching interval4.
Therefore, you should keep track of at what interval you are working at the moment and create another variable for that..
120  General Category / General Discussion / Re: Arduino Tinkerkit on: March 11, 2014, 05:33:10 pm
Hi Sharkfin, and welcome to this community.

Dannable is right, this kit doesn't include the Uno and it is expensive at € 119.85 (converted by Google).
The kit is offered at € 69.90 from the Arduino site, but you need to add VAT to that (i doubt that will add over 70 %).
By the way, both say they're out of stock now.

If you do not yet have an Arduino, you might want to consider the starter kit.
It costs 10 more euro's, which would be some 8.35 pounds.
It does have an Uno and a project book.
It doesn't have modules like the tinkerkit but it does have an LCD screen, a servo and a small motor, some sensors.
So you can work with light, sounds and movement.

Sorry for making this a harder decision to you.
Pages: 1 ... 6 7 [8] 9 10 ... 91