Show Posts
Pages: [1] 2 3 ... 263
1  Community / Exhibition / Gallery / Example of a state machine on: Today at 02:04:59 am
Hi all,

Thought I'd share this.

I implemented a state machine turnstile (I prefer turnstYle but wth, no biggy....)  based on what I read here. The attached code is fully commented but in essence it takes care of these events:

Current     Event    Transition   New
   state                            state
 -------------------------------------------
 Locked      Coin     Unlock       Unlocked (normal operation)
 Unlocked    Pass     Lock         Locked   (normal operation)
 Locked      Pass     Alarm        Locked   (abnormal operation: forced entry)
 Unlocked    Coin     Thanks       Unlocked (abnormal operation: paid twice)


In a nutshell, it starts locked, you pay, it unlocks, you open, enter, close and it locks. If you pay once it's unlocked, thanks for the donation, you paid twice. If you open without paying, alarm.

My turnstile isn't mechanically correct: it's just a short metal strip on a hinge. One end rests on an electromagnet, and there's an optointerrupter half way along. The optoint detects the presence of the strip, the magnet locks it in place. Lifting the strip is like pushing into the turnstile, dropping it is like the stile closing behind you. You can lift the strip against the magnet to simulate an illegal entry.

Payment is by clicking a software debounced momentary switch, which simulates a coin drop.

This implementation does not worry about the stile being open, ie sort of hovering between  "clicks"; perhaps PhaseII could look for that and alarm on a timeout, meaning someone is trapped or it didn't click closed properly.

You're welcome to do whatever you like with this.....

2  Using Arduino / Project Guidance / Re: Is 5.5volts from external regulator to Vin pin enough?? on: Today at 12:27:13 am
The output will be 5.5 volts, which will be terminated on the Arduino's Vin and Gnd pins.

According to this spec site, the Vin input should be between 7 to 12 volts:

Will this work?

I'm pretty sure you already answered your own question....
3  Using Arduino / Project Guidance / Re: Getting wrong result from PWM on: July 25, 2014, 04:30:07 am
Not clear to me if this "controller" is the Arduino or another device connected to it?
4  General Category / General Discussion / Re: don't understand the meaning of a warning in a motor driver board user guide on: July 25, 2014, 04:16:26 am
I have a feeling your English is better than theirs.....
5  Using Arduino / Installation & Troubleshooting / Re: Maybe a stupid question, but how to you prevent old code from running... on: July 24, 2014, 09:30:10 pm
Correct me if I'm wrong,
Assuming you're running a relativly stock arduino without sd card reader or other storage,
when you upload the next sketch/program into the arduino the previous one gets erased from the arduino.
The memory it is stored in is non volitile (does not wipe as soon as power is lost) memory..

True but that's not what the OP's asking. His concern is that if he builds circuit B and powers up, the old sketch for circuit A will run before he loads the new sketch for circuit B, and that could have consequences.
6  Using Arduino / Installation & Troubleshooting / Re: Maybe a stupid question, but how to you prevent old code from running... on: July 24, 2014, 09:20:12 pm
Not sure if it's standard or not... standard (as in most common) is probably to build the new circuit under power and risk shorting something.

I think there's even been a suggestion to load BareMinimum when you've finished playing: that way next time you power up, the board's in a known condition, especially if you have many boards and just grab one.

7  Using Arduino / Installation & Troubleshooting / Re: Maybe a stupid question, but how to you prevent old code from running... on: July 24, 2014, 09:13:05 pm
There are a number of threads that suggest you may be right.

So what you could do is:

  • Power Arduino down
  • Dismantle old circuit
  • Power up, old sketch runs but no circuit attached
  • Load Bare Minimum sketch (empty setup() & loop()- File > Examples > 01 Basics)
  • Power down
  • Mantle* new circuit
  • Power up (Bare Minimum runs)
  • Load new sketch

*Well, if dismantle means take something apart, mantle must mean build it in the first place?
8  Using Arduino / Motors, Mechanics, and Power / Re: L293D no power on output on: July 23, 2014, 01:59:21 pm
It's a bit difficult to follow your wiring from those pics. Can you do a quick hand-drawn sketch of your wiring, exactly as you have it, including the power for the motor and the chip, and the chip enable?

edit.... you sure you have voltage on the ends of the battery wires?
9  Using Arduino / Motors, Mechanics, and Power / Re: L293D no power on output on: July 23, 2014, 01:39:37 pm
The pic has Arduino outputs on 5, 6, 9 and 10.... so if you have it wired like that you should be using 5 & 6 or 9 & 10, not 11 & 12.
10  Using Arduino / Programming Questions / Re: LED/Photocells with Relay Module on: July 23, 2014, 11:54:58 am
First step is to forget about the program as such- at least in a formal, code sense- and list in detail exactly what the steps are. You have it in your mind I guess, and listed it in broad outline already, but now you need to list it more fully.
11  Using Arduino / Sensors / Re: LM34 Temp Sensor on: July 23, 2014, 05:03:31 am
Regarding a and c in previous reply, no you don't have to set the pin as an input and yes you can reference an analog pin as 0. The analogRead takes care of it realising it's analog pin 0 not digital pin 0.

I have this in code for example, and don't set the pin as input first:

Code:
 temp=0;
  for(byte i=0; i<5; i++)  //average 5 reads
  {
    temp=temp + analogRead(0)/2;  // should be 500/1024 but wth its close enough
    delay(100);
  }

12  Using Arduino / Programming Questions / Re: Set All Pins to Output on: July 22, 2014, 11:23:50 pm
I would still like a breakdown explanation, more - so this part:  i<=19; i++

As LarryD suggested, did you read this: http://arduino.cc/en/Reference/For ?

The "i<=19" part is your test.... while i is <= 19, do the increment (the "i++" part)  and go again. Once i>19, you're done.
13  Using Arduino / Project Guidance / Re: LCD Clock on: July 22, 2014, 10:54:17 am
You probably have it unzipped at the wrong level.

When I unzipped it into the library folder I got datetime inside datetime, which is an extra level. If you got that you need to do away with the outer datetime folder and move everything up one level.
14  Using Arduino / Project Guidance / Re: LCD Clock on: July 22, 2014, 10:27:33 am
How do I get that library, then?

Over 12 million Google hits for "datetime.h" and the first one's a winner....

http://playground.arduino.cc/Code/dateTime
15  Using Arduino / Project Guidance / Re: LCD Clock on: July 22, 2014, 10:06:27 am
To be honest, I don't know.

That'll be a "no" then, since it's not a standard library and you would know if you had installed it.

I get the exact same message trying to compile your code and I don't have that library.
Pages: [1] 2 3 ... 263