Show Posts
Pages: 1 ... 100 101 [102] 103 104 ... 356
1516  Using Arduino / Programming Questions / Re: restart program? on: November 03, 2013, 09:35:46 am
You seem to be displaying a series of digits for 1 second each then making an instant check on buttons to see if you should exit the series or start displaying from index 9. The 3rd button does nothing. And you do that twice with a different set of digits in the second series.
The button must be making contact at the instant it is checked to work.

I don't know what you want it to do differently. I'm not sure of what it does now in the larger sense, especially not the why and what for sense. I see user I/O that could lead to some unexpected results that might benefit from waiting for a button to be released before proceeding might help out.

 
1517  Using Arduino / Microcontrollers / ZIF Mega48 dev board is 168 compatible. on: November 02, 2013, 09:39:01 am
http://dx.com/p/diy-m48-ex-standard-development-board-blue-169248

Quote
Supports ATmega48 / ATmega88 / ATmega168 / ATmega8 series

Only thing I don't like is the crystal and that can be changed.


1518  Community / Bar Sport / Re: Your latest purchase on: November 01, 2013, 05:07:20 pm
I was shopping for solid-state disk drives online. What do you think of this one?




Check warranty terms. See if they have a factory warranty. What they had last time I bought was a dealer warranty. Once of that was enough for me. The company won't back their own $#!+3 directly.


1519  Using Arduino / Programming Questions / Re: restart program? on: November 01, 2013, 08:34:52 am
Now it always resets the counter to 24, but I also want it to reset to 14, I don't know if that's possible.

How is it supposed to know which to reset the counter to, 24 or 14?

........

As far as time the idea is to not restart the clock but rather save the value of millis at the start time and watch the clock for when the clock millis minus the start millis is more than or equal to the desired interval.

In a plain example, if I want to do something an hour from 3:00 then I wait until 4:00 - 3:00 >= 1 hour. I don't reset the clock to 12:00 every time I want to time something. Imagine if I wanted to time 2 events that start at different times, that second reset will screw up timing the first event if it hasn't already happened.

Instead of a 12 hour clock we have a 4-billion-and-some millisecond clock that takes 49.7-some days to go around.

This is something that once you understand the POV, you will see it's very useful even for what you want.
1520  Using Arduino / Programming Questions / Re: Doing two things at once, can someone point me in the right direction? on: October 31, 2013, 07:37:45 pm
Yes, the next concept to marry in with the timers is the state machine, or finite state machine however you might name it.

The do many things at once (real time tasking) idea is to keep loop() running as fast as you can for quick response while doing the different many things one at a time on each pass through and make a control system to select which code to run on any certain pass through.

In Nick's example everything is controlled by time. A state machine controls by what is going on, the process state. But there is nothing to say that you can mix the two or have a state machine within a state machine. These are techniques, not religions.

In a simple state machine I might print a menu and watch Serial for a single digit choice number then either take an action based on a valid choice or print an error message on invalid choice. In my example there are only 2 choices on the menu so that leaves me with at least 5 states.

state - action
-------------------
0 - print menu
10 - get choice
100 - do choice 1
150 - do choice 2
200 - error

Inside loop() I put a switch-case statement with one case for every state.

switch (state)
{

  case 0
  print the menu and change the state value to 10
  break

  case 10
  if ( Serial.available() )
  {
    read Serial
    switch ( read_char )
    {
      case '1'
      change state to 100
      break

      case '2'
      change state to 200
      break

      default
      change state to 200
    }
  }
  break

  case 100
  do whatever menu choice 1 should do
  break
   
  case 150
  do whatever menu choice 2 should do
  break

  case 200
  print bad menu choice user error message
  change state to 0

  default
  print special alert the programmer error in the code message, this should never be reached

}

And I use that breakdown as comments to help fill in the actual code.

Note that for the do menu choice cases that those may be broken up into more than one case and should be if there is any delay in time or waiting for a response (perhaps a sub-menu and user response but maybe waiting for a pin to go HIGH or LOW) then one case does everything up to that wait then changes to state to the next that waits for Serial or checks the pin and simply lets loop() run again until the response is detected.

ALWAYS keep whatever section of code is to run short. NEVER BLOCK.

One thing to do is to add a blinking led (like good old pin 13 led) as a running status indicator. If you can see that not blinking right (once per second) then you have a hangup in your code.
1521  Using Arduino / Programming Questions / Re: Doing two things at once, can someone point me in the right direction? on: October 31, 2013, 05:54:36 am
lazaah, have a look at this blog by Nick Gammon.

How to do multiple things at once ... like cook bacon and eggs
http://www.gammon.com.au/forum/?id=11411

It's a full, sensible, easy explanation with code included.



Where to get started is right there:
http://www.gammon.com.au/forum/?id=11411

1522  Community / Bar Sport / Re: VOID ON WARRANTY!!!! why? You modified it... on: October 31, 2013, 01:23:33 am
Psychically, physically... what's the difference?

Ask Uri Geller. He says you just have to want the spoon to bend and it does so maybe you just don't want enough for the warranty to bend.

3rd time: did the firmware come with a warranty voided clause? Or was it 3rd party as now seems to be the case?

I refuse to buy anything Seagate over their idea of warranty and refusal to have a drive reformatted. I have a whole trail of people who won't buy their junk including 1 or 2 who did and got burned. I doubt that Seagate notices but that's tough as two of those people are hardware decision making executives.  smiley-grin F Seagate!

1523  Community / Bar Sport / Re: Your latest purchase on: October 30, 2013, 09:35:39 pm
That latest Rush album, Clockwork Angels, is strongly influenced by steampunk. It's pretty good.
1524  Community / Bar Sport / Re: VOID ON WARRANTY!!!! why? You modified it... on: October 30, 2013, 09:33:26 pm
Quote
Did you read anything except the last few sentences?

Question is, did that firmware update come with a warranty-voiding agreement that you might have clicked your way right through?

Or are you only interested in presenting a limited set of 'facts'?
1525  Community / Bar Sport / Re: VOID ON WARRANTY!!!! why? You modified it... on: October 30, 2013, 05:22:48 am
If you can prove a way to psychically modify hardware then James Randi will award you $1,000,000.

I really doubt that Toyota would refuse mandated brake work over a changed music system.

Question is, did that firmware update come with a warranty-voiding agreement that you might have clicked your way right through?



Did you read anything except the last few sentences?

I read the whole thing. MY last sentence should tell you that. Did you read it?
1526  Community / Bar Sport / Re: VOID ON WARRANTY!!!! why? You modified it... on: October 30, 2013, 01:41:00 am
If you can prove a way to psychically modify hardware then James Randi will award you $1,000,000.

I really doubt that Toyota would refuse mandated brake work over a changed music system.

Question is, did that firmware update come with a warranty-voiding agreement that you might have clicked your way right through?
1527  Community / Bar Sport / Re: New Arduino intel processor board on: October 30, 2013, 01:31:42 am
Do you have any idea how many 8051's were made just by Intel? And they licensed them. 8051's and derivatives are still made today and still bring money to Intel. How embarrassing!
1528  Community / Bar Sport / Re: New Arduino intel processor board on: October 29, 2013, 05:56:27 pm
I think that Intel has just a little experience with microcontrollers and not just the 8051.
1529  Using Arduino / Programming Questions / Re: Trying to understand given code errors. on: October 29, 2013, 12:27:34 pm
Thank you for the help. I created the code from scratch. This is my first term taking a robotics class and this is my mid-term project. I think I should be able to fix it now from your answers.

Good job then! Most times it's "I grabbed this code, fix it please!".

The Arduino IDE has an Auto-Format that sets the indents right but your sketch has to compile for it to work. My usual method is to AF with every chunk of code I add right from the start. Having the braces on their own lines at matching level makes level-checking far easier.

if ( blahblah )
{
  do the thing
}

is easier to check than

if ( blahblah ) {
  do the thing
}

when there's many of them differently nested.

Same goes for leaving spaces around parenthesis to make them easily clear. At a glance (1) takes a fraction longer than ( 1 ) to scan and uses a grain less mental energy. When you spend hours and hours coding, it adds up.

These seem like little things but the difference made is in you (tiredness, longer time debugging) more than the code.

1530  Community / Bar Sport / Re: New Arduino intel processor board on: October 29, 2013, 05:20:31 am
Transputer is better?
Pages: 1 ... 100 101 [102] 103 104 ... 356