Poll
Question: Can anyone help me design a program for a Light and temperature controller
Programming - 1 (33.3%)
General help - 2 (66.7%)
Total Voters: 2

Pages: [1]   Go Down
Author Topic: Student needs help!  (Read 725 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an assignment to complete for uni and i am struggling to understand the module at the mo, struggling how to write the program. Anyone help please?

Here is what i have been set -

Light and Temperature Alarm Controller

Make a system that performs the following two tasks at the same time:-

·         An alarm should sound if the temperature of a piece of equipment rises above 60 oC.
·         A light should be controlled that comes on when it is dark.

Hints.

Use a piezo buzzer for the alarm, and a white LED for the light.
Use a thermistor and 4.7kΩ resistor to sense the temperature.
Use an LDR and 4.7kΩ resistor to sense the temperature.
Use two “trimmer type” potentiometers to set the levels of voltage at which lights and alarms go on.
You will thus use four ADC channels.

Thank you
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 217
Posts: 13742
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


You have to start reading here - http://www.arduino.cc/en/Tutorial/HomePage -

especially these
- http://arduino.cc/en/Tutorial/AnalogInput
- http://arduino.cc/en/Tutorial/Tone
- http://arduino.cc/en/Tutorial/BlinkWithoutDelay (for understanding multitasking)
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I do not think you need multitasking for this to operate as expected.

This might get you somewhere:
Code:
/*
An alarm should sound if the temperature of a piece of equipment rises above 60 oC.
A light should be controlled that comes on when it is dark.

Use a piezo buzzer for the alarm, and a white LED for the light.
Use a thermistor and 4.7kO resistor to sense the temperature.
Use an LDR and 4.7kO resistor to sense the light.
Use two “trimmer type” potentiometers to set the levels of voltage at which lights and alarms go on.
You will thus use four ADC channels.
*/

//variables for the pin
const byte ledPin = 13;
const byte piezoPin = 11;
///TODO continue adding your variables

void setup() {
pinMode(ledPin,OUTPUT);
pinMode(piezoPin,OUTPUT);
}

void loop() {
  checkTemperature();
  checkIfLightShouldTurnOn();
  delay(500);
}

///TODO implement comments
void checkTemperature() {
  //read the threshold value from the temperature threshold trimpot
  //read the value from the thermistor
  //check the value against the value from the thermistor
  //if (thermistorValue > threshold) {
    tone(piezoPin,440,1000);
  //}
}

///TODO implement comments
void checkIfLightShouldTurnOn() {
  //read the threshold value from the light threshold trimpot
  //read the value from the LDR
  //check the value against the value from the LDR
  //if (ldrValue < threshold) {
    digitalWrite(ledPin,HIGH);
  //} else {
    digitalWrite(ledPin,LOW);
  //}
}

That code will block the processing of light conditions while sounding the alarm, and it will check two times a second (1000/500 = 2) maximum because of the delay() in the loop.

Happy coding!
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Wow, it is amazing how your question is written exactly as a homework assignment would be stated.  What are of the odds of that happening?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 217
Posts: 13742
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 
Quote
What are of the odds of that happening?

loop()
{
  Serial.println("100%");
}
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 616
Posts: 49444
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
loop()
{
  Serial.println("100%");
}

Where's the setup() function?
Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Where is the return type?

Now, this was fun  smiley-wink
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I didn't assign this. Can't be my student. Relieved.
See, when I started my projects, I started from tutorial on analog read and lcd print. Then resistor sorter with two resistors in series. Then temperature sensor. This homework is a bit of a shock if the student didn't do any guided tutorials.
Logged


Pages: [1]   Go Up
Jump to: