Show Posts
Pages: 1 ... 7 8 [9] 10 11 ... 91
121  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):
0  OFF

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).
122  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:
if (stro1num == 1)   //first blink on
  if(curstro1Millis - prestro1Millis > stro1interval1) {digitalWrite(stro1Pin, HIGH); stro1num = 2;}

You should also be able to do this:
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.
123  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.
124  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 ?
125  Community / Bar Sport / Re: whats with the attitude on: March 13, 2014, 01:53:18 am
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.
126  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:
     if (buttonState5 == HIGH)
      if (buttonPushCounter > 127) {        // This is new
        buttonPushCounter = 127;            // So is this

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.
127  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.
128  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.
129  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.

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..
130  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.
131  Using Arduino / LEDs and Multiplexing / Re: led strobe without delays help? on: March 11, 2014, 04:57:58 pm

You need to keep track of what you're doing and have been doing.
You also need to ask yourself if you really need to use that extra function (void strobeflash() ), but in this case that doesn't really matter.

Keeping track of what you're doing requires some extra variables.
This variable is a flag that tells you in what state you are, and this approach is also known as a state machine (you can and should do some research on that).
It will allow you to skip or do some part of your code, depending on a decision that was made earlier.
In this case, the lapse of strobetimer should trigger some flag, and that flag (together with strobetimer itself) should also be reset at some place in your sketch.

There is absolutely no difference to the blink without delay sketch here.
Try to build code and show it.
There will be someone that tells you where you're doing the right thing and where not.
You will only learn by doing, make mistakes and understand those mistakes.
132  International / Nederlands / Re: logging en pulsenteller on: March 11, 2014, 01:08:10 pm
Beste Ben, welkom op het forum.

Omdat dit voor een schoolopdracht is, is het de bedoeling dat je dit zelf doet.
We zijn ons er hier erg van bewust dat hier vaak gezocht word naar oplossingen voor schoolopdrachten, en daarom is de kans heel klein dat iemand je gaat voordoen wat je moet doen.
Niet dat ik dat in je vraag lees, maar puur voor de duidelijkheid.

Je vertelt hier niet wat je probleem is, ook niet wat je opdracht precies behelst, en niet wat je wil meten.
Alleen dat je 'iets' moet doen met 3 analoge ingangen (waarom zijn dat er 3 en geen 5 ofzo ?) en een pulsingang.

Ik heb wel een tipje voor je.
Het forum kan doorzocht worden met gebruik van Google.
Helemaal rechts boven in het scherm kun je zoeken (het vakje is wellicht wat lastig te zien want weinig kleurverschil).
Als je gaat zoeken, moet je een slimme zoekterm gebruiken en das er eentje waarvan je mag verwachten dat die niet in ieder onderwerp voor zal komen.
Zoeken naar "sketch" of "code" is dus niet handig.
Maar je hebt het woord "trapas" al in de virtuele mond genomen.
En wie weet is er ook nog iets te vinden met het woord "fiets".
Beide zijn wel Nederlandstalige woorden, dus als je iets gaat vinden zal dat onwaarschijnlijk in een andere taal zijn.
En ze hebben ook erg weinig met Arduino, maar wie weet wat je gaat vinden..
(ik dus wel :p)
133  Using Arduino / LEDs and Multiplexing / Re: led strobe without delays help? on: March 10, 2014, 05:26:53 pm

Posted a lot on your first day (haven't seen the other posts yet).
But still, slow down.

Let me ask you first to read this (click !).
It is on top in every part of the forum, and tells you how to use it.
Don't think you know all that, just read it once or twice and use the information.

So next time you post some code, put it in code tags like this:[code] put it here [/code].

Your code can't be right.
You are trying to work with something that constantly changes (time), but you are assigning constants to it, even though you do not define them as such.

void setup()   {              
  // initialize outputs:
  pinMode(ledPin9, OUTPUT);
  strobetimer = millis ();
  strobetime1=millis();   // set time as now
  strobetime2=millis()+30; //first strobe duration
  strobetime3=millis()+100;   // short wait
  strobetime4=millis()+150; //second strobe duration
  strobetime5 = 1000; //long wait
This is effectively assigning constants.
Setup is only run once.
Read millis() as "now".
Then you set strobetime1 to now, exaclty like you described.
And strobetime2 to now (a fraction later than the now in strobetime1) + 30 milliseconds
And so on.

Then you are checking to see some things are true, but at least after the first iteration they are always true.
void strobeflash ()  {

    // Strobe Sequence :
 //   strobetime1=millis();   // set time as now

    if(millis()>strobetime1) // first strobe flash
      digitalWrite(ledPin9, HIGH);   // set the LED on
    if(millis()>strobetime2) // short wait
      digitalWrite(ledPin9, LOW);    // set the LED off
    if(millis()>strobetime3) // second strobe flash
      digitalWrite(ledPin9, HIGH);   // set the LED on
    if(millis()>strobetime4) // end of second flash
      digitalWrite(ledPin9, LOW);    // set the LED off

The short wait might be an actual wait only the first iteration, after that millis will for sure always be > strobetime2
So your sketch can't do what you expect it to do.

What you might want to do, is this:
 strobetime1=millis();   // set time as now
  const long strobetime2=30;     //first strobe duration
  const long strobetime3=100;   // short wait
  const long strobetime4=150;   //second strobe duration
  const long strobetime5 = 1000; //long wait
And then check to see what timers have elapsed by comparing them to a variable that was set by millis() when strobeinterval lapsed.
Because you are comparing to a long (millis()), you should use a long here too.

Study blink without delay some more.
134  Using Arduino / General Electronics / Re: why I need resistors on: March 10, 2014, 04:49:57 pm
Hi mike007, and welcome.

Lots of comments to your question here.
But don't think you asked a dumb question, there's only 1 dumb question and that is the one that was never asked.
Resistors and some other 'basic' components have multiple uses.
Therefore your question can't be answered like that.
Fellow countryman nicoverduin tried to explain a bit, and LarryD showed some links that in turn show a bit of the diversity of usefulness of resistors (and that's not all there is by far).
Besides resistance, voltage and current, there is more to keep in mind like maximum power (some call this "wattage") and voltage a resistor can withstand.
Sometimes even inductance.
But still resistance, voltage and current are the first things you need to understand.

So you should always put these questions in a context.
If you have a question about some resistor in a specific setup, ask and tell about that setup.
That will make it easier to explain to some and the replies easier to understand for the others.
135  General Category / General Discussion / Re: testing something on: March 10, 2014, 02:08:49 am
I know how to use code tags.

Is there a way that I can have
[ code ] and [ /code ]
but without the spaces
in a post?
(To trick the html/bb editor like?)

If there is a code tags sticky somewhere, point me to that.

In my post i did show a line containing code tags without spaces.

[code]There's no spaces here[/code]

If this isn't it, sorry for not understanding what else you're asking for.
This is where you can get some information about SMF codes.
Pages: 1 ... 7 8 [9] 10 11 ... 91