I am in need of a motion sensor for something, and I have this HamShield that I got from KickStarter recently.
heres some code I have mashed together that *MIGHT* make the radio send an SSTV image when motion is triggered..
I have to rest it and refine it first! its just mashed code from examples!
[su_expand more_text=”Code:” less_text=”Close Code.”]/* Morse Code Beacon Test beacon will transmit and wait 30 seconds. Beacon will check to see if the channel is clear before it will transmit. */ // Include the HamSheild #include #define PWM_PIN 3 #define RESET_PIN A3 #define SWITCH_PIN 2 // Create a new instance of our HamSheild class, called ‘radio’ HamShield radio; int calibrationTime = 30; boolean sensorActive = false; boolean previousSensorState = false; int pirPin = 4; //the digital pin connected to the PIR sensor’s output // Run our start up things here void setup() { // NOTE: if not using PWM out, it should be held low to avoid tx noise pinMode(PWM_PIN, OUTPUT); digitalWrite(PWM_PIN, LOW); pinMode(pirPin, INPUT); digitalWrite(pirPin, LOW); // prep the switch pinMode(SWITCH_PIN, INPUT_PULLUP); // set up the reset control pin pinMode(RESET_PIN, OUTPUT); digitalWrite(RESET_PIN, HIGH); // Set up the serial port at 9600 Baud Serial.begin(9600); // Send a quick serial string Serial.println(“HamShield FM Beacon Example Sketch”); // Query the HamShield for status information Serial.print(“Radio status: “); int result = radio.testConnection(); Serial.println(result,DEC); // Tell the HamShield to start up radio.initialize(); radio.setRfPower(0); // Configure the HamShield to transmit and recieve on 446.000MHz radio.frequency(145570); Serial.println(“Radio Configured.”); Serial.println(“Sensor Calibration in Progress”); Serial.println(“——————————“); for(int i = 0; i < calibrationTime; i++){ Serial.print(“.”); } Serial.println(“”); Serial.println(“Sensor Calibration Completed”); Serial.println(“Sensor Reading Active”); delay(50); sensorActive = false; previousSensorState = false; } void loop() { // takes the pin value and saves it to the sensorActive boolean value if(digitalRead(pirPin) == HIGH) { sensorActive = true; radio.setModeTransmit(); // Turn on the transmitter delay(250); // Wait a moment radio.SSTVTestPattern(MARTIN1); // send a MARTIN1 test pattern delay(250); radio.setModeReceive(); // Turn off the transmitter } if(digitalRead(pirPin) == LOW) { sensorActive = false; delay(250); } // performs action if the state of the sensor changes // since this is a loop, here is now it works: // if the sensor pin goes HIGH (on) after it being LOW (off), the sensorActive value changes from the previousSensorState value. // it then turns on the LED. when the pin goes LOW (off) it will do the same thing but opposite values. // it also prints status to serial. it will print the time of triggering by providing the number of seconds that have passed since the program started. if(sensorActive != previousSensorState) { if(sensorActive == true) { previousSensorState = sensorActive; Serial.println(“—“); Serial.print(“Motion Detected At: “); Serial.print(millis()/1000); Serial.println(” Seconds”); delay(50); } if(sensorActive == false) { previousSensorState = sensorActive; Serial.println(“—“); Serial.print(“Motion Stopped At: “); Serial.print(millis()/1000); Serial.println(” Seconds”); delay(50); } } } [/su_expand]