Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Help with multiple motion sensors on: October 17, 2012, 08:47:38 am
Thanks for the compliment, tell me if am wrong, if I erased that part from the code Im going to lost the pcounter that I need to count, or not?
2  Community / Gigs and Collaborations / Help with this please!! on: October 17, 2012, 08:37:52 am
I have this code:
Code:
#include <OneWire.h>
#include <DallasTemperature.h>

//TODO: Investigate the ~ in beside the port number in the board (e.g., ~3 vs 4)

#define ONE_WIRE_BUS 4    //temperature on port 4

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x43, 0xC2, 0x03, 0x04, 0x00, 0x00, 0x85 };

volatile boolean r1IsEvent;
volatile boolean r2IsEvent;
volatile int pcounter;

int RELAY = 13;  //pin for the RELAY

void setup(void)
{
  Serial.begin(9600);
  
  sensors.begin();
  
  sensors.setResolution(insideThermometer, 10);
  r1IsEvent = false;
  r2IsEvent = false;
  pcounter =
  //attach receiver one to pin 2
  attachInterrupt(0, receiverOneChanged, FALLING);
  //attach receiver one to pin 3
  attachInterrupt(1, receiverTwoChanged, FALLING);
  
}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
    Serial.print(" F: ");
    Serial.print(DallasTemperature::toFahrenheit(tempC));
  }
}

void loop(void)
{
  delay(4000);
  Serial.print("Here we go!!!...\n\r");
  sensors.requestTemperatures();
  
  Serial.print("The temperature is: \n\r");
  printTemperature(insideThermometer);
  Serial.print("\n\r");
  Serial.print("We got it!!!!\n\r");
  Serial.print("\n\r");
  Serial.print("\n\r");
  Serial.print("\n\r");
}


void receiveOneChanged(){
   r1IsEvent = true;
  if(r2IsEvent){
     r1IsEvent = false;
     r2IsEvent = false;
     //person exit
     pcounter = pcounter - 1;
     if(pcounter == 0){
       digitalWrite(RELAY, LOW);
     }    
  }
}

void receiveTwoChanged(){
  r2IsEvent = true;
  if(r1IsEvent){
     if(pcounter == 0){
       digitalWrite(RELAY, HIGH);
     }
     r1IsEvent = false;
     r2IsEvent = false;
     //person entered
     pcounter = pcounter + 1;    
  }
}

///////////////////////////
I need to fix this code. Ive been trying different resources but im not getting any help. Can someone help me?? If i need to pay for the help consider that im a student and not working. thanks

Moderator edit: Code (tags) fixed. No charge.
3  Using Arduino / Programming Questions / Re: Help with multiple motion sensors on: October 17, 2012, 08:12:00 am
And what i need to do in that case?? Erase that line??
4  Using Arduino / Programming Questions / Re: Help with multiple motion sensors on: October 17, 2012, 07:51:47 am
i did the change but now I have this error:

allan_temp_sensor.cpp: In function 'void setup()':
allan_temp_sensor:30: error: void value not ignored as it ought to be
5  Using Arduino / Programming Questions / Re: Help with multiple motion sensors on: October 17, 2012, 06:30:32 am
I think that I need more help with this. im not so clear with what i need to do.
6  Using Arduino / Programming Questions / Re: Help with multiple motion sensors on: October 17, 2012, 06:17:34 am
?????
7  Using Arduino / Programming Questions / Re: Help with multiple motion sensors on: October 17, 2012, 06:09:46 am
Where I need to add the lines?? Can you show me that please??
8  Using Arduino / Programming Questions / Re: Help with multiple motion sensors on: October 17, 2012, 06:04:28 am
these are the errors:


allan_temp_sensor.cpp: In function 'void setup()':

allan_temp_sensor:30: error: 'receiverOneChanged' was not declared in this scope

allan_temp_sensor:32: error: 'receiverTwoChanged' was not declared in this scope
9  Using Arduino / Programming Questions / Re: Help with multiple motion sensors on: October 17, 2012, 06:01:37 am
what you mean, the error??
10  Using Arduino / Programming Questions / Help with multiple motion sensors on: October 17, 2012, 05:49:47 am
Hi there:

Im making a project where I have 2 motion sensors in line. The thing is that i want to detect when a person enter and exit from a room and at the same time has a counter. To be more specific, I called one of the sensor r1 and the other one r2, If the person enters, r1 turn on first and then r2, and viceversa, if the person exits r2 turn on first and then r1. In the same code Im making a reading from the temperature in the room. I have this code but it gave me an error and I cant figured it out.

#include <OneWire.h>
#include <DallasTemperature.h>

//TODO: Investigate the ~ in beside the port number in the board (e.g., ~3 vs 4)

#define ONE_WIRE_BUS 4    //temperature on port 4

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x43, 0xC2, 0x03, 0x04, 0x00, 0x00, 0x85 };

volatile boolean r1IsEvent;
volatile boolean r2IsEvent;
volatile int pcounter;

int RELAY = 13;  //pin for the RELAY

void setup(void)
{
  Serial.begin(9600);
 
  sensors.begin();
 
  sensors.setResolution(insideThermometer, 10);
  r1IsEvent = false;
  r2IsEvent = false;
  pcounter =
  //attach receiver one to pin 2
  attachInterrupt(0, receiverOneChanged, FALLING);
  //attach receiver one to pin 3
  attachInterrupt(1, receiverTwoChanged, FALLING);
 
}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
    Serial.print(" F: ");
    Serial.print(DallasTemperature::toFahrenheit(tempC));
  }
}

void loop(void)
{
  delay(4000);
  Serial.print("Here we go!!!...\n\r");
  sensors.requestTemperatures();
 
  Serial.print("The temperature is: \n\r");
  printTemperature(insideThermometer);
  Serial.print("\n\r");
  Serial.print("We got it!!!!\n\r");
  Serial.print("\n\r");
  Serial.print("\n\r");
  Serial.print("\n\r");
}


void receiveOneChanged(){
   r1IsEvent = true;
  if(r2IsEvent){
     r1IsEvent = false;
     r2IsEvent = false;
     //person exit
     pcounter = pcounter - 1;
     if(pcounter == 0){
       digitalWrite(RELAY, LOW);
     }   
  }
}

void receiveTwoChanged(){
  r2IsEvent = true;
  if(r1IsEvent){
     if(pcounter == 0){
       digitalWrite(RELAY, HIGH);
     }
     r1IsEvent = false;
     r2IsEvent = false;
     //person entered
     pcounter = pcounter + 1;   
  }
}
11  Community / Gigs and Collaborations / Re: Help with a code on: October 16, 2012, 10:16:54 am
Oh ok i prefer a new code from someone else, because maybe Im doing something wrong.
12  Community / Gigs and Collaborations / Help with a code on: October 16, 2012, 08:30:46 am
Hi there and thanks for the help in advance:

I need a code that when a motion sensor detects something it prints "Motion detected" in the serial monitor. I know is simple, but Im having issues with these. I have a code done, but it dont print nothing in the monitor. I dont know if i asked for the help in the right place. Thanks.
13  Using Arduino / Programming Questions / Re: Help combining these 2 sketches on: October 10, 2012, 10:39:04 am
Thanks for the help, I use the code from @Crossroads and works fine.

@PaulS : Yes, thats what im trying to do, but im having issues with the motion sensor.

14  Using Arduino / Programming Questions / Help combining these 2 sketches on: October 10, 2012, 10:10:37 am
How I can combine these 2 codes in 1?

first code:

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 3

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x43, 0xC2, 0x03, 0x04, 0x00, 0x00, 0x85 };

void setup(void)
{
  Serial.begin(9600);
 
  sensors.begin();
 
  sensors.setResolution(insideThermometer, 10);
 
}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
    Serial.print(" F: ");
    Serial.print(DallasTemperature::toFahrenheit(tempC));
  }
}

void loop(void)
{
  delay(5000);
  Serial.print("Here we go!!!...\n\r");
  sensors.requestTemperatures();
 
  Serial.print("The temperature is: \n\r");
  printTemperature(insideThermometer);
  Serial.print("\n\r");
  Serial.print("We got it!!!!\n\r");
  Serial.print("\n\r");
  Serial.print("\n\r");
  Serial.print("\n\r");
}


second code:

const byte ledPin =  13;    // LED pin
const byte motionPin = 2;   // motion detector input pin
byte senseMotion = 0;       // variable to hold current state of motion detector

void setup() {
  // set the digital pin directions
  pinMode(ledPin, OUTPUT);     
  pinMode(motionPin, INPUT);
}

void loop()
{
    // Now watch for burglers
    senseMotion = digitalRead(motionPin);
    if (senseMotion == HIGH) {    // burgler found!
      digitalWrite(ledPin, HIGH);
    } else {                      // no burgler, yet...
      digitalWrite(ledPin, LOW);
    }
}
15  Using Arduino / Project Guidance / Re: Help with a project that i want to create!! on: September 02, 2012, 07:15:20 am
Ok, what about this:

I want to create for the main door these components together:
breadboard with xbee, pir sensor and a battery setup or any kind of power supply.


in the computer: arduino with the other xbee.

The problem is:
I want the IP camera to take a snapshot when the pir sensor detects any motion, and then I want this picture to be sent to the computer to be analyzed with face recognition.

Im having issues with all the connections. Thanks for the help.
Pages: [1] 2