Show Posts
Pages: 1 [2] 3 4 ... 96
16  Using Arduino / Programming Questions / Re: Delay() function in setup() on: July 12, 2014, 08:35:57 pm
[hint]
One thing that I like about the Arduino is how easy it is to try things for yourself.
[/hint]
And that uploading nonsense code to it won't break it. It just won't work with that code.
17  Using Arduino / Programming Questions / Re: 4 momentaries used in pairs gives 16 strings - how2send on press of 2nd of pair? on: July 12, 2014, 08:25:06 pm
Thank you. And, exactly on the, "Start writing that function first."
I'll hunt around, read about 'functions', 'calling a function twice in a loop'
then I'll post the hulking mess here hoping for pointers.
The first button/pedal pressed will be 1, 2, 3 or 4.
Subtract 1 from the number = 0 - 3.
Multiply by 4 = 0, 4, 8 or 12 .
Put it in a variable.
Read the second button's number and subtract 1 = 0 - 3
Add it to your variable. Your variable will now contain a number from 0 to 15.
You could act on those numbers, but I like to keep 0 for 'no button pressed'.
So add 1 to your variable = 1 - 16.
Now look up the 'switch case' construct in reference.
18  Using Arduino / Programming Questions / Re: Trying to get single button to start / stop a show - non-blocking on: July 12, 2014, 07:29:42 pm
Code:
// boolean ShowStarted = LOW; error that showStated was not declared in void loop scope
ShowStarted !== showStated.
19  Using Arduino / Project Guidance / Re: Newbie project - measuring light weight and send signals on: July 12, 2014, 07:13:47 pm
Hi, Henry, yes thats why I said.

Quote
This would be good to measure how much someone has drunk
You claimed that the waiter would know when the customer is drunk. I'm saying that that isn't possible, from the coaster alone. The waiter would still have to use their judgement, as they do now, to tell if the customer is drunk. I, therefore, see little advantage in the coaster for that purpose. There may be other purposes that the OP has in mind for it.
Quote
I agree there are lots human variables involved.
Variables that make it impossible for the waiter to tell, from the coaster alone, whether the customer is drunk.
20  Using Arduino / Project Guidance / Re: Mobile Rotary Phone on: July 12, 2014, 06:53:37 pm
Wiring the hook as the power switch would extend your battery life.

It would, but then how does one ring in to the phone?
Ooops! But you'd get no nuisance calls.  smiley-grin
21  Community / Bar Sport / Re: The Cracked Pot on: July 12, 2014, 12:21:15 am
Maybe you should read more.

I only say about not taking such tales literally because so many here do in the usual pull from context to fit whatever you want to force down someone else's life manner.
Now you're talking about the REAL crackpots, who take their religious books as literally true.
As literally true springboards to make incredible leaps of hypocrisy from.
We Brits suffer from less of them than you USians, but we still have them.  smiley-sad
22  Using Arduino / Programming Questions / Re: How to produce low frequency pulse width modulation using millis() ? on: July 11, 2014, 11:49:16 pm
All your time variables should be unsigned longs.
Why are you declaring current and current2 again in loop() when they're declared already?
If you want the LED to alternate between on and off, you'll need a flag to keep track of it's state. Try this:

or:

Code:
void loop()
{
  if (millis()-current < 8000UL ) digitalWrite(ledPin,HIGH);
  else if (millis()-current < 12000UL) digitalWrite(ledPin,LOW);
  else current = millis();
}
Neat, except he wants the on time to be 4000 and the off time to be 8000. All he needs to do is to change the first line.
23  Using Arduino / Programming Questions / Re: 4 momentaries used in pairs gives 16 strings - how2send on press of 2nd of pair? on: July 11, 2014, 11:30:17 pm
Hit any 2 button and specific data (for the pair) is send only when 2nd of a pair is hit - then returns to zero state waiting for next pair to be pressed
You'll need to look up, read and understand:
Finite State Machine,
Debounce
and 'Blink without delay', if you need all 16 combinations.
24  Using Arduino / Project Guidance / Re: Mobile Rotary Phone on: July 11, 2014, 11:02:39 pm
Two comments.
1) I know they're called 'rotary' phones in the US, but elsewhere in the English speaking world they're known as 'dial' phones, as the phone itself isn't usually rotary, only the dial. The phones fitted in kiosks [booths] were fixed in place and couldn't be rotated.
2) The phone had to be 'off the hook' before you dialled a number, so that you could listen for the dialling tone. Wiring the hook as the power switch would extend your battery life. You might also like to use the tone library to produce a fake dialling tone. Google 'dialling tone frequency' to see what that is in the US. I know, in the UK, it's 425Hz. It varied slightly from one exchange to another in the days of Strowger (electro-mechanical) gear, but it's standardised at that frequency in modern electronic exchanges.
25  Using Arduino / Project Guidance / Re: Visually recognize a number - dumb energy meters on: July 11, 2014, 10:16:35 pm
Further to what I wrote above, there's nothing to stop you (other than cost or space) having a second, private meter fitted AFTER the supply company's meter, that you can get to the dial on. The readings on this may not be exactly  the same as those on the supply company's meter, but should be fairly close. You will, of course, have to observe all the safety rules that apply in your jurisdiction.
26  Using Arduino / Project Guidance / Re: Newbie project - measuring light weight and send signals on: July 11, 2014, 09:56:49 pm
Hi, if you  know the mass of an empty glass, then you can program in limits, only transmit that the glass needs refilling if the coaster detects a mass between and empty glass and a 1/4 full (optimist) glass.
If measured mass is less than empty glass, then the  glass must have been picked up, so don't panic and call a waiter the glass will be back.

This would be good to measure how much someone has drunk.

We have liquor laws in Australia that makes it illegal to sell alcohol to a drunk person, but it happens.
This way the waiter will know how much has been drunk in any period and know when the customer is drunk.
Only if there are also scales on the chair. A 7 stone [98lbs] woman and a 20 stone [280lbs] man can consume vastly different amounts of alcohol before they're inebriated drunk pissed as newts!  smiley
Also, how would the waiter know, from the coaster, if they've each drunk half a bottle of vodka before entering the establishment?
It reminds me of the idiocy of speed cameras. Yes, they reduce speed as claimed, but only for 50 yards before and 50 yards after the camera.
27  Community / Bar Sport / Re: The Cracked Pot on: July 10, 2014, 11:52:24 pm
Maybe you should read more.

I only say about not taking such tales literally because so many here do in the usual pull from context to fit whatever you want to force down someone else's life manner.
Now you're talking about the REAL crackpots, who take their religious books as literally true.
28  Community / Bar Sport / Re: Is it just me, or.... on: July 10, 2014, 11:43:13 pm
And all of a sudden there are a lot of questions about clocks and displaying the time!

When do the schools/colleges start their holidays??
Depends on the country. In the UK, about the 20th of July for schools. Colleges may be earlier. It's a long time since I was in formal education  smiley
29  Using Arduino / Programming Questions / Re: State machine modeling on: July 10, 2014, 11:20:56 pm
Yep Robin that's more or less my thinking: I'd go for a state of "Card swiped" as an intermediate step.

So Event: Swipe from State: Locked will give State: Card swiped.

Event: Coin from State: Card swiped will give State: Unlocked.

Event: Swipe from State: Card swiped will remain at State: Card swiped

Event: Timeout from State: Card swiped will revert to State: Locked

Event: Coin from State: Locked will remain at State: Locked (ie card swipe must precede coin insertion.)

This is fun  smiley-cool .... purely academic, and it's clarifying a lot of state machine stuff which is all good.
That's it, but I would rename some of your states to make the sequence clearer.
Locked, waiting for card.
Card swiped, waiting for coin.
I would also include user prompts like lighting a LED by the card reader when a card is to be read, lighting a LED by the coin slot when a coin is needed and lighting a green LED when access is permitted and a red LED when access is denied.
30  Using Arduino / Programming Questions / Re: How to produce low frequency pulse width modulation using millis() ? on: July 10, 2014, 10:40:09 pm
All your time variables should be unsigned longs.
Why are you declaring current and current2 again in loop() when they're declared already?
If you want the LED to alternate between on and off, you'll need a flag to keep track of it's state. Try this:
Code:
const int ledPin =  2;      // the number of the LED pin           
unsigned long current = 0;        // will store last time LED was updated
unsigned long current2 = 0;
unsigned long period = 4000;           
unsigned long offtime = 8000;
boolean flagLED =false; //LED off at start
void setup() {
  pinMode(ledPin, OUTPUT);   
  current=millis() ;   
}

void loop(){
   if(millis()-current > offtime && flagLED ==false) {
         digitalWrite(ledPin,HIGH);
         current2=millis();  //set start of wait time for switch off
         flagLED = true;
   }
   if(millis()-current2 > period && flagLED==true) {
         digitalWrite(ledPin,LOW);
         current=millis(); //set start of wait time for switch on
         flagLED==false;
   } 
}
Pages: 1 [2] 3 4 ... 96