Вы находитесь на странице: 1из 3

//start of program

int buzzpin= 9; //declare digital output 9 for buzzer


int turnoff = 3; //declare digital output 3 for reset button
int var =0; // for continuous loop function
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
//initialize output mode for buzzer
pinMode(buzzpin,OUTPUT);
buzz(200); //sound check
}

void loop() {
// initialize output mode for LED
pinMode(7, OUTPUT);
pinMode(turnoff, INPUT_PULLUP);
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (15.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
delay(1000);

while (voltage < 3.2 ) {


return; //looping back the program to earlier point if no heat is detected
}
//set timer for optimum noodle cooking time for 3 minutes
delay (30*1000); //30 second delay
delay (30*1000); //30 second delay
The arduino can only accept
delay (30*1000); //30 second delay minimum delay for 30 seconds
only. There about 6 lines were
delay (30*1000); //30 second delay
added to reach the 3 minutes
delay (30*1000); //30 second delay delay

delay (30*1000); //30 second delay

while(var<1) {
Serial.println(voltage);
buzz(200); //warns the user the noodle is already cooked
delay(20);
if (digitalRead(turnoff) == LOW) { //program detects the reset button is pressed
analogWrite(buzzpin,0); // turn off the buzzer
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
// delay to ensure the thermocouple has already cooled down from the heat
delay(30*1000);//30 second delay 2 minutes delay were
delay(30*1000); //30 second delay introduced to ensure the
thermocouple have cooled
delay(30*1000); //30 second delay down sufficiently from intense
heat induced from the noodle
delay(30*1000); //30 second delay
cup
break;
}
}
delay(2000); //stablilize buzzer

void buzz(unsigned char time) // declaring buzzer function

{
analogWrite(buzzpin,20); // produce sound to buzzer
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
delay(time);
analogWrite(buzzpin,0); // turn off the buzzer
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(time);
}

//end of program

Вам также может понравиться