Question

create and design the ultimate smart home using various senors, in C+ + program

create and design the ultimate smart home using various senors, in C+ + program
0 0
Add a comment Improve this question Transcribed image text
Answer #1

smart home using various senors:

1)Window & door open and close:

// doors open or closed

#include <bits/stdc++.h>

using namespace std;

  

// Function to check whether 'n'

// has even number of factors or not

bool hasEvenNumberOfFactors(int n)

{

    int root_n = sqrt(n);

    // if 'n' is a perfect square

    // it has odd number of factors

    if ((root_n*root_n) == n)

        return false;

    // else 'n' has even

    // number of factors

    return true;

}

// Function to find and print

// status of each door

void printStatusOfDoors(int n)

{

    for (int i=1; i<=n; i++)

    {

        // If even number of factors

        // final status is closed

        if (hasEvenNumberOfFactors(i))

            cout << "closed" << " ";

        // else odd number of factors

        // final status is open

        else

            cout << "open" << " ";

    }

}

// Driver program

int main()

{

    nt n = 5;

    printStatusOfDoors(n);

    return 0;

}

2)WIRELESS DOORBELL:

#include <RH_ASK.h>

#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver;

void setup()

{

Serial.begin(9600); // Debugging only

pinMode(5,INPUT);

if (!driver.init())

Serial.println("init failed");

}

void loop()

{

if(digitalRead(5)==HIGH){

const char *msg = "a";

driver.send((uint8_t *)msg, strlen(msg));

driver.waitPacketSent();

delay(200);

}

}

Doorbell Receiver Code

#include <RH_ASK.h>

#include <SPI.h> // Not actualy used but needed to compile

#include "pitches.h" //add Equivalent frequency for musical note

#include "themes.h" //add Note vale and duration

RH_ASK driver;

void setup()

{

Serial.begin(9600); // Debugging only

if (!driver.init())

Serial.println("init failed");

else

Serial.println("done");

}

void Play_Pirates()

{

for (int thisNote = 0; thisNote < (sizeof(Pirates_note)/sizeof(int)); thisNote++) {

int noteDuration = 1000 / Pirates_duration[thisNote];//convert duration to time delay

tone(8, Pirates_note[thisNote], noteDuration);

int pauseBetweenNotes = noteDuration * 1.05; //Here 1.05 is tempo, increase to play it slower

delay(pauseBetweenNotes);

noTone(8); //stop music on pin 8

}

}

void loop()

{

uint8_t buf[1];

uint8_t buflen = sizeof(buf);

if (driver.recv(buf, &buflen)) // Non-blocking

{

Serial.println("Selected -> 'He is a Pirate' ");  

Play_Pirates();

Serial.println("stop");

}

}

3)Turning LED on and off with C++:

#include <Arduino\SerialClass.h>
#include "Send.h"
#include "led.h"

namespace ledtest {
Serial* SP = new Serial("COM3");

[STAThread]
void main(array<String^>^ args) {

Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);

ledtest::led form;
Application::Run(%form);
}

void sendState(int state) {
if (state == 1)
SP->WriteData("1", 1);
if (state == 0)
SP->WriteData("0", 1);
}

void readState() {
char* iState;

while (SP->IsConnected()) {
SP->ReadData(iState, 255);
printf(iState);
}
}

The button click events are as follows:

private: System::Void btnHigh_Click(System::Object^ sender, System::EventArgs^ e) {
ledtest::sendState(1);
}
private: System::Void btnLow_Click(System::Object^ sender, System::EventArgs^ e) {
ledtest::sendState(0);
}

Add a comment
Know the answer?
Add Answer to:
create and design the ultimate smart home using various senors, in C+ + program
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider a Smart Home Environment. Smart home consists of various devices that are providing diff...

    Consider a Smart Home Environment. Smart home consists of various devices that are providing different types of functionalities. Some devices are monitoring the environment of the smart home (temperature, air quality) etc. Some are monitoring health conditions of individuals. Some devices are focusing on operations of a smart home (dishwasher, washing machine, etc.). Some can be entertainment devices. You can include other devices and functionalities as well. Information generated in a smart home is sensitive in nature. Suppose you were...

  • Home Tool Sign in CIV 481. Sunna IQ Share Use only the ultimate-strength design (strength design)...

    Home Tool Sign in CIV 481. Sunna IQ Share Use only the ultimate-strength design (strength design) and calculate the design strength (ultimate strength capacity "*Mn") of the beam section given below. Total area of 4 steel bar #11 is equal to 6.25 in² ft = 4700 psi and fy = 75,000 psi. (25 points) & Do 20 in. 4 in. N D 32 in. 4# 11 3 in. 12 in.

  • Part 1: Explore the Smart Home Step 1: Understanding the devices that comprise the smart home...

    Part 1: Explore the Smart Home Step 1: Understanding the devices that comprise the smart home Commonly ISPs deliver data and video over a single coaxial cable. Starting from the attic, a coaxial splitter is used to separate the video signal from the data signal. a. Two coaxial cables leave the coaxial splitter in the topology shown. Which devices does the coaxial cable connect to? ____________________________________________________________________________________ b. The cable modem is the interface between the ISP’s network and the home’s...

  • Please explain how the smart home system circuit design below is connected and designed. The smar...

    Please explain how the smart home system circuit design below is connected and designed. The smart home will be able to automatic on/off light through motion sensor, automatic on/off fan after reaching 27 degree, send email when detect smoke. The bulb was changed into a LED which is connected directly to the relay instead of parallel with the fan. PIR MQ-2 ESP8266 DHT22 13S Arduino LCD Karakter 16x2 AC Socket fritzing PIR MQ-2 ESP8266 DHT22 13S Arduino LCD Karakter 16x2...

  • in python create a program to display the cost of renting a smart car. the user...

    in python create a program to display the cost of renting a smart car. the user must be able to enter the number of days he/she rents the cat and the number of miles driven. use constants for the flat rate per day and the flat rate per mile. the program will display the flat rate per day, flat rate per mile, and the total cost of the car rental.

  • Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program...

    Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program should have an array of 5 integers named lottery and should generate a random number in the range of 1 through 99 for each element of the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that...

  • Create a program using C# the is a CHECKING account program. the program should display the...

    Create a program using C# the is a CHECKING account program. the program should display the customers name (Last name, Fitst name), the customers ADDRESS, the custeomers BIRTHDAY, the customer SOCIAL SECURITY NUMBER, customers PIN NUMBER.

  • Create a C++ program to design some sort of object. Examples: Tree, Flower, House, Bike, Sun,...

    Create a C++ program to design some sort of object. Examples: Tree, Flower, House, Bike, Sun, Fruit, or just anything.

  • C++ Design: Create a UML Class diagram that reflects the software design of your entire program...

    C++ Design: Create a UML Class diagram that reflects the software design of your entire program Q3. Create a class called Passenger that represents passengers of an airline company. A passenger is defined by the following information: - Passenger ID (int) - Name (string) - Address (string) - Tel (string) - Date of birth (of type Date from Q2) Provide the following functions: - A constructor that initializes the data members and provides default arguments. - Accessor methods that return...

  • Create a design document for a program that will take a number from the user and...

    Create a design document for a program that will take a number from the user and convert it to IEEE single precision format. The program displays the IEEE representation (Single precision) of the number entered by the user. PLEASE ADD THE PSEUDOCODE AND CODE WITH C PROGRAMMING

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT