Go Down

Topic: Student needs help! (Read 826 times) previous topic - next topic

leeg11

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

robtillaart


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)
Rob Tillaart

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

AlphaBeta

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

This might get you somewhere:
Code: [Select]
/*
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!

James C4S

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?
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

robtillaart

Quote
What are of the odds of that happening?


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

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

PaulS

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


Where's the setup() function?

AlphaBeta

Where is the return type?

Now, this was fun  ;)

liudr

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.

Go Up