sensor, led, lcd, bluetooth and buzzer

Dependencies:   mbed beep TextLCD

main.cpp

Committer:
afqbot
Date:
2021-07-06
Revision:
0:899b65e1a7da

File content as of revision 0:899b65e1a7da:

#include "mbed.h"
#include "TextLCD.h"
#include "beep.h"

DigitalIn Sensor1(PC_1); //sensor 1
DigitalIn Sensor2(PC_2); //sensor 2
DigitalIn Sensor3(PC_3); //sensor 3
PortOut LED(PortB, 0x03); //LED
TextLCD lcd(PB_4, PB_5, PB_6, PB_8, PB_9, PB_10); //LCD
Beep buzzer(PB_2); //buzzer
Serial bluetooth(PA_9, PA_10); //bluetooth

    float value;

int main()
{
    bluetooth.baud(9600);
    
    while(1){
        Sensor1 == 0; //sensor 1 OFF
        Sensor2 == 0; //sensor 2 OFF
        Sensor3 == 0; //sensor 3 OFF
        LED == 0x01; //LED green ON
        lcd.cls();
        lcd.printf("ALL OKAY");
        bluetooth.readable();
        
        
        if (Sensor1 == 1){ //sensor1 ON
            LED == 0x02; //LED red On
            lcd.cls();
            lcd.printf("INTRUDER ALERT");
            buzzer.beep(1000,1.0);
            }
            
            else if (Sensor2 == 1){ //sensor2 ON
                LED == 0x02; //LED red ON
                lcd.cls();
                lcd.printf("IMTRUDER ALERT");
                buzzer.beep(1000,1.0);
                }
                
                else if (Sensor3 == 1){ //sensor3 ON
                    LED == 0x02; //LED red ON
                    lcd.cls();
                    lcd.printf("INTRUDER ALERT");
                    buzzer.beep(1000,1.0);
                    }
                }
            }