Show Posts
|
|
Pages: 1 [2] 3 4 ... 1321
|
|
20
|
Using Arduino / Programming Questions / Re: Help on error codes
|
on: May 22, 2013, 09:33:02 am
|
#include <LiquidCrystal.h> // import the library LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// data and control lines String adjusts[]={ " iDeas"," Adjust seconds"," Adjust minutes"," Adjust hours"};// set text values for adjust menu int adjustmode=0; // the track of the adjust menu int hour=0; // the count of hours upon which we can make the mathematical operations int minute=0; // the count of minutes upon which we can make the mathematical operations int second=0;// the count of seconds upon which we can make the mathematical operations String hourstring="";//the output variable component for hours String minutestring="";//the output variable component for minutes String secondstring="";//the output variable component for seconds long timethen=0;//the variable to hold a sample of the time in seconds boolean runbutton=false; //the variable to control the run button boolean alarmon=false;// the switch for the alarm boolean pause=false;// the track for the pause void setup(){ lcd.begin(16,2);//start the LCD module lcd.clear();//clear down residual text lcd.print(adjusts[0]);//printout start screen } void loop(){ int timezero=hour+minute+second ; if (runbutton==false&&adjustmode==0&&digitalRead(6)==HIGH&&timezero>0){ runbutton=true; timethen=millis(); }//sets condition for running the timer on buttonpress and samples time if (runbutton==false&&digitalRead(7)==HIGH&&alarmon==false){//starts loop if not running countdown and adjust button has been pressed lcd.setCursor(0,0); lcd.print(" ");//clears top line of module adjustmode++; if(adjustmode==4){ adjustmode=0; }//increment variable and reset at 4 lcd.setCursor(0,0); lcd.print(adjusts[adjustmode]);// set to top line and print out what to adjust delay(500);//wait for half a second } if(runbutton==false&&adjustmode==1&&digitalRead(8)==HIGH){ second++; delay(500); if(second==60){ second=0; } } //increment seconds by 1 if(runbutton==false&&adjustmode==1&&digitalRead(9)==HIGH){ second--; delay(500); if(second==-1){ second=59; } } //decrement seconds by 1 if(runbutton==false&&adjustmode==2&&digitalRead(8)==HIGH){ minute++; delay(500); if(minute==60){ minute=0; } } //increment minutes by 1 if(runbutton==false&&adjustmode==2&&digitalRead(9)==HIGH){ minute--; delay(500); if(minute==-1){ minute=59; } } //decrement minutes by 1 if(runbutton==false&&adjustmode==3&&digitalRead(8)==HIGH){ hour++; delay(500); if(hour==60){ hour=0; } } //increment hours by 1 if(runbutton==false&&adjustmode==3&&digitalRead(9)==HIGH){ hour--; delay(500); if(hour==-1){ hour=59; } } //decrement hours by 1 if (runbutton==true&&pause==false&&digitalRead(7)==HIGH){ pause=true; delay(1000); timethen=timethen+1000; }//switch pause on if (runbutton==true&&pause==true&&digitalRead(7)==HIGH){ pause=false; delay(1000); timethen=timethen+1000; }//switch pause off if (runbutton==true&&digitalRead(8)==HIGH){ hour=0; minute=0; second=0; runbutton=false; }//clears the countdown and resets to zero if (pause==true){ timethen=millis(); }//track time in pause mode if(runbutton==true&&pause==false){// ** all the lines following marked with //** are active only when running if (millis()-timethen>=1000){ timethen=millis(); second=second-1; tone(10,50,10); }//**as a second passes drop down seconds and make tick sound if (second==-1) { second=59; minute=minute-1; }//**as a minute passes drop down minutes if (minute==-1) { minute=59; hour=hour-1; }//**as an hour passes drop down hours if(hour==-1){ hour=0; }//**reset hours to 0
}
if (runbutton==true&&hour==0&&minute==0&&second==0){ alarmon=true; runbutton=false; }// set conditions for end of run(time remaining is zero) if (hour<10){ hourstring="0"; hourstring=hourstring+hour; } else { hourstring=String(hour); // <<< I FIXED THIS LINE }//setup for hour output if (minute<10){ minutestring="0"; minutestring=minutestring+minute; } else { minutestring=minute; // << You can fix this one }//setup for minute output if (second<10){ secondstring="0"; secondstring=secondstring+second; } else { secondstring=second; // << you can fix this one }//setup for second output String outstring=hourstring+":"+minutestring+":"+secondstring;//compound string for output lcd.setCursor(4,1); lcd.print(outstring);//set position and print compound string if (alarmon==true){// activates at end of run time tone(10,444,10);//outputs tone if (digitalRead(6)==HIGH){ alarmon=false; pause=false; } }//switches off tone when run button is pressed } Don't forget to tell us your grade.
|
|
|
|
|
21
|
Using Arduino / Programming Questions / Re: Help on error codes
|
on: May 22, 2013, 09:20:17 am
|
|
The fix I gave you (and another similar couple of instances of the same) fixed it for me. Well, it compiled - beyond that, I'm not interested - I don't have your hardware (actually, I don't even have an Arduino)
What errors are you getting now? Post your code
|
|
|
|
|
26
|
Using Arduino / Programming Questions / Re: Help on error codes
|
on: May 22, 2013, 08:12:01 am
|
Auto-format works wonders: #include <LiquidCrystal.h> // import the library LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// data and control lines String adjusts[]={ " iDeas"," Adjust seconds"," Adjust minutes"," Adjust hours"};// set text values for adjust menu int adjustmode=0; // the track of the adjust menu int hour=0; // the count of hours upon which we can make the mathematical operations int minute=0; // the count of minutes upon which we can make the mathematical operations int second=0;// the count of seconds upon which we can make the mathematical operations String hourstring="";//the output variable component for hours String minutestring="";//the output variable component for minutes String secondstring="";//the output variable component for seconds long timethen=0;//the variable to hold a sample of the time in seconds boolean runbutton=false; //the variable to control the run button boolean alarmon=false;// the switch for the alarm boolean pause=false;// the track for the pause void setup(){ lcd.begin(16,2);//start the LCD module lcd.clear();//clear down residual text lcd.print(adjusts[0]);//printout start screen } void loop(){ int timezero=hour+minute+second ; if (runbutton==false&&adjustmode==0&&digitalRead(6)==HIGH&&timezero>0){ runbutton=true; timethen=millis(); }//sets condition for running the timer on buttonpress and samples time if (runbutton==false&&digitalRead(7)==HIGH&&alarmon==false){//starts loop if not running countdown and adjust button has been pressed lcd.setCursor(0,0); lcd.print(" ");//clears top line of module adjustmode++; if(adjustmode==4){ adjustmode=0; }//increment variable and reset at 4 lcd.setCursor(0,0); lcd.print(adjusts[adjustmode]);// set to top line and print out what to adjust delay(500);//wait for half a second } if(runbutton==false&&adjustmode==1&&digitalRead(8)==HIGH){ second++; delay(500); if(second==60){ second=0; } } //increment seconds by 1 if(runbutton==false&&adjustmode==1&&digitalRead(9)==HIGH){ second--; delay(500); if(second==-1){ second=59; } } //decrement seconds by 1 if(runbutton==false&&adjustmode==2&&digitalRead(8)==HIGH){ minute++; delay(500); if(minute==60){ minute=0; } } //increment minutes by 1 if(runbutton==false&&adjustmode==2&&digitalRead(9)==HIGH){ minute--; delay(500); if(minute==-1){ minute=59; } } //decrement minutes by 1 if(runbutton==false&&adjustmode==3&&digitalRead(8)==HIGH){ hour++; delay(500); if(hour==60){ hour=0; } } //increment hours by 1 if(runbutton==false&&adjustmode==3&&digitalRead(9)==HIGH){ hour--; delay(500); if(hour==-1){ hour=59; } } //decrement hours by 1 if (runbutton==true&&pause==false&&digitalRead(7)==HIGH){ pause=true; delay(1000); timethen=timethen+1000; }//switch pause on if (runbutton==true&&pause==true&&digitalRead(7)==HIGH){ pause=false; delay(1000); timethen=timethen+1000; }//switch pause off if (runbutton==true&&digitalRead(8)==HIGH){ hour=0; minute=0; second=0; runbutton=false; }//clears the countdown and resets to zero if (pause==true){ timethen=millis(); }//track time in pause mode if(runbutton==true&&pause==false){// ** all the lines following marked with //** are active only when running if (millis()-timethen>=1000){ timethen=millis(); second=second-1; tone(10,50,10); }//**as a second passes drop down seconds and make tick sound if (second==-1) { second=59; minute=minute-1; }//**as a minute passes drop down minutes if (minute==-1) { minute=59; hour=hour-1; }//**as an hour passes drop down hours if(hour==-1){ hour=0; }//**reset hours to 0
}
if (runbutton==true&&hour==0&&minute==0&&second==0){ alarmon=true; runbutton=false; }// set conditions for end of run(time remaining is zero) if (hour<10){ hourstring="0"; hourstring=hourstring+hour; } else { hourstring=hour; }//setup for hour output if (minute<10){ minutestring="0"; minutestring=minutestring+minute; } else { minutestring=minute; }//setup for minute output if (second<10){ secondstring="0"; secondstring=secondstring+second; } else { secondstring=second; }//setup for second output String outstring=hourstring+":"+minutestring+":"+secondstring;//compound string for output lcd.setCursor(4,1); lcd.print(outstring);//set position and print compound string if (alarmon==true){// activates at end of run time tone(10,444,10);//outputs tone if (digitalRead(6)==HIGH){ alarmon=false; pause=false; } }//switches off tone when run button is pressed }
"Handy REM statements" ?
|
|
|
|
|