Modifications

Sauter à la navigation Sauter à la recherche
21 octets ajoutés ,  14 mai 2014 à 06:51
Ligne 2 : Ligne 2 :     
== Le code ==
 
== Le code ==
The code for a simple alarm with three sensors or branches is shown below.
+
{{bloc-etroit|text=The code for a simple alarm with three sensors or branches is shown below.
    
This configuration has the sensors tied into resistors feeding Pin 3. The Trinket must be programmed out of the circuit as pins 3 and 4 are shared with the USB.
 
This configuration has the sensors tied into resistors feeding Pin 3. The Trinket must be programmed out of the circuit as pins 3 and 4 are shared with the USB.
Ligne 8 : Ligne 8 :  
The program uses the standard Softwareserial library to talk via the Bluefruit EZ-Link on Pin 0 for transmit, Pin 2 for receive. You can eliminate the requirement to specify a receive pin (and shrink the code slightly) with the third party SendOnlySoftwareSerial library on arduino.cc via this forum thread: [http://forum.arduino.cc/index.php?topic=112013.0 http://forum.arduino.cc/index.php?topic=112013.0.].  This would also allow you to use Pin 2 (Analog 1) for alarms, freeing Pin 3 shared with USB.
 
The program uses the standard Softwareserial library to talk via the Bluefruit EZ-Link on Pin 0 for transmit, Pin 2 for receive. You can eliminate the requirement to specify a receive pin (and shrink the code slightly) with the third party SendOnlySoftwareSerial library on arduino.cc via this forum thread: [http://forum.arduino.cc/index.php?topic=112013.0 http://forum.arduino.cc/index.php?topic=112013.0.].  This would also allow you to use Pin 2 (Analog 1) for alarms, freeing Pin 3 shared with USB.
   −
Pin 1, which has the onboard red LED, is used as an indicator on which sensors are tripped. When the alarm is set (no alarms tripped), the LED does not blink. It blinks from 1 to 7 depending when sensors are tripped (1 for #1/PIR, 2 for #2, 3 for #3, 4 for 1 and 2, 5 for 1 and 3, 6 for 2 and 3, and 7 for all sensors tripped). If you decide to use Pin 1 for other purposes, you can do so but with the LED in-circuit it can be tricky. For example, the internal pullup resistor, if enabled, is too weak. You may use a fairly low value external pullup resistor like in the hundreds of ohms if you decide to use the pin for sensors.
+
Pin 1, which has the onboard red LED, is used as an indicator on which sensors are tripped. When the alarm is set (no alarms tripped), the LED does not blink. It blinks from 1 to 7 depending when sensors are tripped (1 for #1/PIR, 2 for #2, 3 for #3, 4 for 1 and 2, 5 for 1 and 3, 6 for 2 and 3, and 7 for all sensors tripped). If you decide to use Pin 1 for other purposes, you can do so but with the LED in-circuit it can be tricky. For example, the internal pullup resistor, if enabled, is too weak. You may use a fairly low value external pullup resistor like in the hundreds of ohms if you decide to use the pin for sensors.}}
    
In the code for the example build, enabling DEBUG (uncommenting the line //#define DEBUG by deleting the // characters) will output the alarm values for the analog pin to the serial connection. You should do this once your circuit is together to ensure the values read by your circuit gives values understood by the code as alarms are set off.
 
In the code for the example build, enabling DEBUG (uncommenting the line //#define DEBUG by deleting the // characters) will output the alarm values for the analog pin to the serial connection. You should do this once your circuit is together to ensure the values read by your circuit gives values understood by the code as alarms are set off.
29 917

modifications

Menu de navigation