Hi so I have this program for a motion but it doesn’t work? what I want to happen is when motion is detected, one LED will come on, and one will turn off then it will print a message on the LCD screen?
How long does the alarm signal remain low? You probably want to use an InterruptIn rather than a DigitalIn for your alarm. On the falling edge, you can set your led states in the interrupt and set a flag but don’t print inside the interrupt.
Your clear screen only gets called once as it is outside the while(1) loop.
Hi Leon,
this is the code now. with an interrupt in and fall edge. I’m not sure how to implement the Lcd screen as when I put it into it it doesn’t seem to work? how do I get it so where the alarm is triggered and its a falling edge, a message will appear on the screen?
thanks
George
#include “mbed.h” #include “C12832.h”
//example using InterruptIn with the input from the PIR motion sensors
InterruptIn alarm(p11);
DigitalOut led(LED1);
DigitalOut flash(LED4);
C12832 lcd(p5, p7, p6, p8, p11);
void flip() {
led = !led;
}
int main() {
alarm.mode(PullUp);
wait(2);
alarm.fall(&flip); // attach the address of the flip function to the falling edge
while(1) { // wait around, interrupts will interrupt
flash = !flash;
wait(0.25);
}
}