Challenge

Project 1

const int light = 5;

const int fan = 4;

const int fire = 2;

int lightbase = 25;

int lightval;

int tempbase = 16;

int tempval;

int firebase = 5;

int fireval;

void setup()

{

lightbase = analogRead(A0);

tempbase = analogRead(A1);

firebase = analogRead(A2);

pinMode(light,OUTPUT);

pinMode(A0, INPUT);

pinMode(fan, OUTPUT);

pinMode(A1, INPUT);

pinMode(fire, OUTPUT);

pinMode(A2, INPUT);

}

void loop()

{

lightval = analogRead(A0);

if(lightval < lightbase)

{

digitalWrite(light, HIGH)

}

else

{

digitalWrite(light, LOW)

}

tempval = analogRead(A0);

if(tempval > tempbase)

{

digitalWrite(fan, HIGH)

}

else

{

digitalWrite(fan, LOW)

}

fireval = analogRead(A0);

if(fireval > firebase)

{

digitalWrite(fire, HIGH)

}

else

{

digitalWrite(fire, LOW)

}

}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.