Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is C language in the Arduino software. So the way Im trying to get this to work is when the temperature is between 29

This is C language in the Arduino software.

So the way Im trying to get this to work is when the temperature is between 29 and 37 nothing happens. When temperature falls under 29 the code activates a motor in reverse direction for one iteration cycle and stops. If the temperature reaches 37 the code activates the motor in the forward direction for one iteration cycle and stops.

This code does all of this except it keeps looping the conditional statement once its met. I'm having difficulty adding in a break statement so the iteration cycle only happens once. Im not sure if im using the correct conditional statements to begin with. Any help is apperciated, thank you.

#include #include "DHT.h" #define dht_apin A0 // Analog Pin sensor is connected to dht DHT;

int dirpin =8; int steppin = 9;

void setup() {

Serial.begin(9600); delay(100);//Delay to let system boot Serial.println("DHT11 Humidity & temperature Sensor "); delay(100);//Wait before accessing Sensor pinMode(dirpin, OUTPUT); pinMode(steppin, OUTPUT); } void loop() {

DHT.read11(dht_apin); Serial.print("Current humidity = "); Serial.print(DHT.humidity); Serial.print("% "); Serial.print("temperature = "); Serial.print(DHT.temperature); Serial.println("C "); delay(3000);//Wait 5 seconds before accessing sensor again.

int distance=0;

{ digitalWrite(dirpin, LOW); // Set the direction. delay(100);

for (i = 0; i<6000; i++) // Iterate for 4000 microsteps. if (DHT.temperature>37) { digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(500); // This delay time is close to top speed for this

} // particular motor. Any faster the motor stalls. }

digitalWrite(dirpin, HIGH); // Change direction. delay(100);

for (i = 0; i<6000; i++) // Iterate for 4000 microsteps if (DHT.temperature<29) { digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step. delayMicroseconds(500); // This delay time is close to top speed for this } // particular motor. Any faster the motor stalls.

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions