Salvius, meet Arduino

Arduino is an open-source electronics prototyping platform based on flexible, easy-to use hardware and software. The Arduino UNO is a small compact programmable board that can process many inputs and outputs. It is being used to manage Salvius's on/off state. Salvius has a primary power switch that has three options; on, off, auto. The 'on' and 'off' selections are pretty self explanatory, but when auto is selected the Arduino is activated. The Arduino is programmed to turn on the robot if there is any rapid change in a selection of environmental variables, ex; light, temperature, sound, barometric pressure, etc...


Here is the code that was used to turn on the robot when heat was detected by the PIR (passive inferred) sensor.

// Turns on a digital pin based on sensor input
// Code by Gunther Cox

//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 3;  
int inputPin = 2;              // choose the input pin (for PIR sensor)
int relayPin = 3;              // digital PWM pin for relay 
int pirState = LOW;            // we start, assuming no motion detected 
int val;                       // variable for reading the pin status
int val2;                      // variable for reading the delayed status
int pirMode = 0;               // variable for activation mode

void setup() {
  delay(5000);                 // pause for five seconds before calibrating sensor
  pinMode(inputPin, INPUT);    // declare sensor as input
  pinMode(relayPin, OUTPUT);   // declare relay as output 
  Serial.begin(9600);          // Set up serial communication at 9600bps
  pirState = digitalRead(inputPin);   // read the initial state

  //begin give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
      Serial.print(".");
      delay(1000);
      }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);
  }
  //end give the sensor some time to calibrate

void loop(){
  val = digitalRead(inputPin);  // read input value and store it in val
  delay(3);                     // 3 milliseconds is a good amount of time
  val2 = digitalRead(inputPin); // read the input again to check for bounces
  if (val == val2) {            // make sure we got 2 consistant readings!
    if (val != pirState) {      // the pir state has changed!
      if (val == LOW) {         // check if the button is pressed
        if (pirMode == 0) {     // relay is off
          pirMode = 1;          // turn relay on!
        } else { 
          pirMode = 0;         // turn relay off!
        }
      }
    }
    pirState = val;            // save the new state in our variable
  }

  // Now do whatever the pirMode indicates
  if (pirMode == 1) {
    digitalWrite(relayPin, HIGH);
    delay(100);
  }
  // If lightmode is 0, do nothing because the relay is already off!
}


The auto activation feature on Salvius is installed in anticipation for an emergency where Salvius might be needed to help someone or act in self-preservation. If there was a fire, a buildup of carbon monoxide, or an unexpected intruder, Salvius could activate and carry out the appropriate actions in only a minutes.

 --------------------------------
Order Details for Arduino Uno
--------------------------------
Item : Arduino Uno USB IO Board
SKU : C-400-DEV-A000046
Quantity : 1
Item Price : $29.95
Item Total : $29.95
--------------------------------

No comments:

Post a Comment