converting Arduino sketch to B4X

Beja

Expert
Licensed User
Longtime User
Built on this project
Here is the code:
Response by PM only please.

int Sensor_pin = 3;
int ledpin = 11;
void setup()
{
pinMode(Sensor_pin, INPUT); // Set the human infraredinterface as the input state
pinMode(ledpin, OUTPUT);
Serial.begin(9600);
Serial.flush();
Serial.println("Ready");
}
void loop()
{
int val = digitalRead(Sensor_pin); // Define parameters to storethe state read by the human infrared senso
if (val == 1) // Buzzer make alarm if someone is detected
{
Serial.println("There is sb moving");
digitalWrite(ledpin, HIGH);
}
else
{
Serial.println("There isn't sb moving");
digitalWrite(ledpin, LOW);
}
delay(100); // Delay 100 milliseconds }[/CODE]
 
Last edited:

thetahsk

Active Member
Licensed User
Longtime User
Search for PIR in the forum
e.g.
 

Beja

Expert
Licensed User
Longtime User
Search for PIR in the forum
e.g.

Thanks thetahsk
In fact I am using the SR505 without problem.. But I want to use a servo motor with it, where there're also so many examples and it's working perfectly if
it's by itself, the thing I am asking for is how can I combine the two.. It's a bird's cage door opener.. if I am close to door (without touching it, the SR505 will pick the IR signal and logs "Detected" At this time I want the servo motor to travel 90 degrees and open the door (a light weight flap).. when I go away and the sensor signal is lost then it will log (Not detected).. At this time I want the servo returns to 0 degree (closes the door), stops the servo and waits for another visit from me. In other words, I want to combine the two Arduino examples and make them one project.
Indeed I will donate for the time if someone managed to do that.
 
Last edited:
Top