Show Posts
|
|
Pages: [1] 2
|
|
3
|
Using Arduino / Programming Questions / Re: How do I stop Time.Alarm in my sketch?
|
on: February 21, 2013, 03:29:12 am
|
my code is redused to minimal so you can understand what I need. so my code needs to be like this ? #include <Time.h> #include <TimeAlarms.h> #include <Stepper.h> int MYType; int resetPin = A2; int addHourPin = A3; int addMinPin = A4; int ID ; int ID2 ; const int stepsPerRevolution = 48; Stepper stepper(stepsPerRevolution, 8, 9, 10, 11); void setup(){ stepper.setSpeed(150); setTime(0,0,0,1,1,11); ID = Alarm.timerOnce(60, spinning); ID2=Alarm.timerRepeat(3600, spinning); // Alarm.timerOnce(60, spinning); //step motor spins 60 sec after boot // Alarm.timerRepeat(3600, spinning); //step motor spins after an hour } void loop(){ RANDOM COMMANDS ;
/*=========== GENERAL reset pin. Everithing resets to zero when presed=============*/ if(digitalRead(resetPin) == HIGH){ Resetingeverithing (); //command to turn off Alarm.timers disable(ID); disable(ID2); setTime(0,0,0,1,1,11); //at this point Alarms are trigered always //command to turn on Alarm.timers enable(ID); enable(ID2); }//end of reset } //END of LOOP
void Resetingeverithing () { Alarm.delay (2000); lcd.clear(); lcd.print("timer will be set back to zero"); //going back to loop } void spinning (){ stepper.step(100); }
because it gives me this sketch_feb21a:41: error: 'disable' was not declared in this scope sketch_feb21a:45: error: 'enable' was not declared in this scope
|
|
|
|
|
4
|
Using Arduino / Programming Questions / How do I stop Time.Alarm in my sketch?
|
on: February 20, 2013, 05:10:43 pm
|
In this sketch I need to add a command ,so I can stop TimeAlarm triger spinning() every time i reset timer (or I add hours with a seccond button). I need spinning triggered 60 sec after turn on or reset and after that ,every hour. thank you #include <Time.h> #include <TimeAlarms.h> #include <Stepper.h> int MYType; int resetPin = A2; int addHourPin = A3; int addMinPin = A4; const int stepsPerRevolution = 48; Stepper stepper(stepsPerRevolution, 8, 9, 10, 11); void setup(){ stepper.setSpeed(150); setTime(0,0,0,1,1,11); Alarm.timerOnce(60, spinning); //step motor spins 60 sec after boot Alarm.timerRepeat(3600, spinning); //step motor spins after an hour } void loop(){ // RANDOM COMMANDS
/*=========== GENERAL reset pin. Everithing resets to zero when presed=============*/ if(digitalRead(resetPin) == HIGH){ Resetingeverithing (); //command to turn off Alarm.timers setTime(0,0,0,1,1,11); //at this point Alarms are trigered always //command to turn on Alarm.timers }//end of reset } //END of LOOP
void Resetingeverithing () { Alarm.delay (2000); lcd.clear(); lcd.print("timer will be set back to zero"); //going back to loop } void spinning (){ stepper.step(100); }
|
|
|
|
|
8
|
Using Arduino / Programming Questions / SOLVED How is "adjustTime(adjustment);" command used ? (time library)
|
on: February 13, 2013, 12:02:40 pm
|
How is "adjustTime(adjustment);" command used ? I want to send a command to my program ,so an hour or a day is added to timer. Later those commands will be sent by the press of a button Is this command ok ? adjustTime(hour()++); #include <Time.h>
void setup() { Serial.begin(9600); Serial.println("sending time to arduino"); setTime(0,0,0,1,1,2000); }
void loop(){ digitalClockDisplay(); delay(1000); }
void digitalClockDisplay(){ Serial.print(day()); Serial.print(" "); Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(" "); Serial.print(day()); Serial.print(" "); Serial.print(month()); Serial.print(" "); Serial.print(year()); Serial.println(); }
void printDigits(int digits){ Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); }
|
|
|
|
|
9
|
Development / Other Software Development / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions
|
on: February 13, 2013, 10:51:00 am
|
How is "adjustTime(adjustment);" command used ? I want to send a command to my program ,so an hour or a day is added to timer. Later those commands will be sent by the press of a button Is this command ok ? adjustTime(hour()++); #include <Time.h>
void setup() { Serial.begin(9600); Serial.println("sending time to arduino"); setTime(0,0,0,1,1,2000); }
void loop(){ digitalClockDisplay(); delay(1000); }
void digitalClockDisplay(){ Serial.print(day()); Serial.print(" "); Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(" "); Serial.print(day()); Serial.print(" "); Serial.print(month()); Serial.print(" "); Serial.print(year()); Serial.println(); }
void printDigits(int digits){ Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); }
|
|
|
|
|
11
|
Using Arduino / Programming Questions / help on time library .unkown commands
|
on: February 11, 2013, 11:02:15 am
|
what is the meaning of those commands in SerialTime example ? #define TIME_MSG_LEN 11 // time sync to PC is HEADER followed by unix time_t as ten ascii digits #define TIME_HEADER 'T' // Header tag for serial time sync message #define TIME_REQUEST 7 // ASCII bell character requests a time sync message ..... time_t requestSync() { Serial.print(TIME_REQUEST); return 0; // the time will be sent later in response to serial mesg
Where can I read about those commands ? I google them and only the SerialTime example came up I read time filefolder and I can't find anithing about those commands (with capital letters like:TIME_MSG_LEN)
|
|
|
|
|
12
|
Using Arduino / Programming Questions / Re: need timer to count and display time from zero to 30 days (day-hour:min:sec)
|
on: February 09, 2013, 09:05:13 am
|
This is what I made 1 year ago .But to succeeded I changed time libraries . Now with a fresh version of arduino ,this cod doesn't run . I lost my changed time library and I cant remember the changes that I have made In this program a counter starts from zero. you can add hours and mins by pressing pins or you can erase timer. Also there is a backup ,every hour, in case of power loss. #include <DateTime.h> #include <LiquidCrystal.h> #include <EEPROM.h> /* LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 * LCD D4 pin to digital pin 5 * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3)./. */ int resetPin = 10; // pin 10 resets the time int addHourPin = 9; int addMinPin = 8; long restoreTime = 0; int restoreDay = 0; int eepromTime = 0; int eepromDay = 0; LiquidCrystal lcd(7, 6, 5, 4, 3, 2);//create object to control an LCD
void setup(){ lcd.begin(16, 4); // set up the LCD's number of columns and rows digitalWrite(resetPin,HIGH); // this line enables pull-up digitalWrite(addHourPin,HIGH);// this line enables pull-up digitalWrite(addMinPin,HIGH);// this line enables pull-up pinMode(13,OUTPUT); // we flash the LED each second pinMode(resetPin, INPUT); // a button on this pin resets the time pinMode(addHourPin, INPUT);//add hours to counter pinMode(addMinPin, INPUT);//add hours to counter DateTime.sync( 0 ); // set time to zero /*Restoring Time after every power failure*/ restoreDay = EEPROM.read(10); //Read days passed restoreTime = EEPROM.read(0); //read hours passed if (restoreDay !=0) { restoreTime = (restoreTime*3600+(restoreDay-1)*86400); //add days and hours to datetima counter DateTime.sync(restoreTime); } delay (30); }
void loop(){ /* --------- Prints time in hours, minutes and seconds ----------- */ DateTime.available(); // needed to refresh the clock time /* GENERAL reset pin. Everithing resets to zero when presed*/ if(digitalRead(resetPin) == HIGH){ for (int u = 0; u < 20; u++) EEPROM.write(u, 0); // write a 0 to all 512 bytes of the EEPROM DateTime.sync( 0 ); // reset time to zero if button pressed } time_t timeNow = DateTime.now(); time_t customTime = timeNow; if(digitalRead(addHourPin) == HIGH){ customTime += (86400 * 1); //add 3600 sec for 1 time(for test,adds a day) DateTime.sync(customTime); // increase hour by one (1 day) } if(digitalRead(addMinPin) == HIGH){ customTime += (60 * 1); delay (100); DateTime.sync(customTime); // increase min by one } //... BACKUP TIME EVERY 1 HOUR...// if ((DateTime.Minute) == 1 && (DateTime.Second)==10 ) { eepromTime = DateTime.Hour; EEPROM.write(10,eepromDay); eepromDay = DateTime.Day ; EEPROM.write(0,eepromTime); } // lcd PRINT lcd.setCursor(0,0); lcd.print("Hr:min:sec"); lcd.setCursor(12,0); lcd.print(DateTime.Hour,DEC); // prints total hours lcd.print(":"); lcd.print(DateTime.Minute,DEC); // and minutes since reset lcd.print(":"); lcd.print(DateTime.Second,DEC); // and sec since reset lcd.print(" "); // clears second digit every minute lcd.setCursor(0,1); lcd.print("Project Day"); lcd.setCursor(13,1); lcd.print(DateTime.Day,DEC); // prints total days lcd.print(" "); /*test perposes lines*/ lcd.setCursor(0,3); lcd.print("epromDay "); lcd.print(eepromDay); lcd.print(" time "); lcd.print( eepromTime ); lcd.print(" "); digitalWrite(13, LOW); //light the LED every second delay (10); digitalWrite(13, HIGH); // }
|
|
|
|
|