With a little’ the time available I thought of putting on a via bluetooth control. The thing is quite simple using those modules available on the market. I took a HC-06, which enables simple communication via serial data. The project is not recent, forgive any lack of inexperience.
I also tried with a PIC 16F84A, with some success, but for scheduling problems microcontroller I suspended the project. A micro rather outdated, but I think I could do it with a 16F628A or 16F182x, which are pin compatible. Also because now I no longer have those microcontrollers in drawers.
It is a simple operation of connecting the outputs of’ Arduino with the following modules and a handful of discrete components to drive a speaker and to remove the’ power to the Bluetooth module in order to disconnect from connected devices when one forgets.
A project consists of Arduino Nano, a Bluetooth module and a relay’ opto-isolated.
The project includes some special features :
The number of exits and ports are configurable via firmware. You have to adjust 2 variables .
The outputs are configurable high or low active. In the default program has taken active low outputs.
The outputs can be configured either as fixed or as timed. L’ Arduino takes care of keeping count, even if those who call the command is no longer present. I do this because I noticed timing programs with your smartphone, which must take the count of the period set. That implies a constant connection with your phone.
commands  They send a command ending through space character or one return-to-head, to the limit when they were sent 6 characters It finishes alone. Why this, for the simple fact that many programs, per Android, do not give the ability to add non-printing characters such as return-to-head.
I chose the program DCmote. Somewhat spartan for configuration, but then easy to understand. Especially for those who do not know much l’ use of smartphone complicated functions. L’ interface specification, and as simple as possible and allows quick access to commands, after having connected to the control.
The control disconnects the’ user inactive (without carriage returns) after 30 seconds. This allows other users to access the control. Maybe it's a bluetooth receiver gap, rather than an improvement. In this way, if one forgets the active connection, It is disconnected and the other members (of my family) They can access commands.
flashing, just to see that the system is up and running.
A command to sound an alarm or a another sound.
Le-mail  e  see lower.
Obviously the transistors are not critical, any NPN and PNP do the work. The R2 has a value of 330 Ohm, so as to drive an LED to be put on the container panel.
The jumpers will be used for on-site programming, removing them one could program the’ Arduino, without interference, but so I inclined so much that I expected hooves to accommodate the Nano. This will avoid possible voltage leaks towards the’ power supply.
L’ power supply must be from 5 Volt stabilized and somewhat robust to power the relay, if powered from the card. Better than both an Ampere.
L’ Arduino not’ included in the print. In this diagram it denotes a series of connectors (4 gives 8 poli) to accommodate the’ Arduino.
The printed below is corretto, to put it on the face coppery.
As defined by the peculiarities you can also modify the firmware in order to obtain the flexibility desired.
 The variables that are used to configure the following:
#define ACTIVE_LOW if it came with commentary line, the outputs become active high. I rele’ I used instead work in negative logic.
#define BUFLENYou are altered if you can use a different capacity from the serial input. For those wishing to modify the firmware for different purposes.
#define OUTPUTMASKIt defines those outputs that will not be affected by a general ignition. In my case, I can not keep closed contact for command defined for use impulse to move the gate. The gate system already has its securities, obviously.
#define NUMTIMERYou are altered if you can determine how many outputs you want to bind. I have a module 4 relay, so there put four. But you can increase up to eight taking into account that assignments defined by the program are the 12,11,10,9 legs, A0, A1, A2, A3. These too can be easily modified, look down.
#define INPUT_TMOa definition of how long to wait before disconnecting an inactive user. The value is in seconds means. The maximum value is 255 (over 4 minutes), without affecting other parts of the program.
array port_pinyou can define which feet assign. From left as first assigned.
As you might guess the values have been put on a list to’ start firmware. For those who understand the programming it will be easy to spot.
 The commands to be sent to the control are such:
For ignition of a fixed output is controlled with a letter capital gives A a H. Interverra’ the limit imposed by how many outputs hath been configured with NUMTIMER.
To start a melody using a letter p, regardless of whether capitalized or miniscola. The melodies are performed in sequence. For the more experienced you can configure it for even play a kind of siren or other. Just put on the list const uint16_t melodyand change TUNENUMwhich establishes how many are. There is a limit in the Mon-Ghezza of an array that is 127. For safety, the only the first charge function 126 values, or stops with two zeros conseguitivi. To clarify, the function expects a pair of values that are the frequency and duration.
To turn off all outputs using the letter xtiny including outputs timed.
For the’ Ignition of all outputs, using a letter Xcapital.They will be excluded those defined not accessible from the output mask.
For commands with timers using the following string:
t (leading character) definition to indicate a timer, no matter whether upper or lower case.
a number from 0 the number of timers defined by the firmware. CAUTION that’ HEX charge for 4 outputs. (second character). Now it only counts 4. If there was enabled serial communication, you see the error messages. So for example 0 a 3. Indexing starts at zero.
sO mor h definition of unit’ measures to set. With s It indicates the seconds, m It will indicate the minutes and h the hours.
by a three-digit valore to set the timer with the previous size desired. For hours is the limit in 9 ore. There may be a problem to set 999 minutes. I think we will update the program early.
a space He concludes the string received. DCmote then the program should set the controls with a termination with space. The return-to-head ends.
For example t3s45, if translates l’ Exit 4 active for 45 seconds.
borderline case, by sending a zero value to a timer, this is concluded.
The package It is always available in its entirety including the sketch for Arduino. If there was some difficulty in compiling it, let me know.
I also made the program that converts RTTTL in values to be loaded into C. As you can notice from the listing there are several melodieI converted my program. Included in package. To function need python version 3.5 .
https://www.elettroamici.org/wp-content/uploads/2019/12/pic2.jpg5761024Picmicro675http://www.elettroamici.org/wp-content/uploads/2017/08/FAVICON-1-300x271.pngPicmicro6752019-12-21 14:28:462020-01-10 19:35:03Control with Bluetooth Nano