This code was originally set as part of a class exercise/task several semesters ago when I started Programming.The task is to write some code for a basic alarm using set variables for the designated alarm time. I want to make it so when my Alarm is active an audio file (sound of an alarm) is played, the alarm should only last 8 seconds, during which time my forever loop --my while loop printing a full stop every second-- is paused for this amount of time after which it should return back to printing a series of full stops every second
- //import processing.video.Movie;
- int alarm_time;
- int alarm_hour;
- int alarm_minute;
- int current_time;
- int t,count;
- boolean alarm;
- void setup(){
- //Set alarm time
- alarm_hour = 17;
- alarm_minute = 54;
- //Define alarm time & curent time
- alarm_time = alarm_hour + alarm_minute;
- current_time = hour() + minute();
- }
- void draw(){
- //"forever while loop" infinite loop, prints (or rather should) a full stop every half second
- boolean always_true = true;
- while( always_true ){
- print( "." );
- for( int i = 0; i < 1000000000; i++ ){
- float result = sqrt( 257 );
- if(alarm){
- // increase the count-variable every second
- if ((millis()-t)/1000>count) {
- print(++count+" ");
- }
- // disable alarm after 8 seconds
- if (millis()-t > 8000) {
- alarm = false;
- }
- //activate alarm
- if(alarm_time == current_time){
- println();
- println("ALARM!!!");
- print("Counting: ");
- t = millis();
- count = 0;
- alarm = true;
- }
- }
- }
- }
- }
- //new Movie(this,"alarm.m4v");
1