Exemplo n.º 1
0
void loop()
{
      val=encoder/faktor;
 
      if (val < minimum)
            {val=minimum;
             encoder=minimum*faktor;}
    
      if (val > maximum)
            {val=maximum;
             encoder=maximum*faktor;}

  if (val !=val_old)
   { 
    // Serial.print (encoder);
    // Serial.print (" ");
    // Serial.print (val);
    // Serial.print (" ");
     
      val_old=val;
      
         sprintf(buffer,"%3d",val);
         digitalWrite(stepper_enable, LOW);
        
         lcd.setCursor(10, 2);
         lcd.print(buffer);
       
       //lcd.cursorTo(1, 10); 
      // lcd.printIn(buffer);
      
        stepper.step(100);

   } 


digitalWrite(stepper_enable, HIGH);
          if (abs (val - stepper_position) >10)
          { lcd.setCursor(19, 3);
            lcd.blink();}
         
          stepper.step(val - stepper_position);
         
          lcd.noBlink();
   
digitalWrite(stepper_enable, LOW);
stepper_position=val;
}
Exemplo n.º 2
0
// Allows the user to choose whether they want to use
//		a default heating curve or define their own curve
// Returns the user's choice
boolean CurveInput::chooseCurve()
{
	printWelcome(WELCOME_DURATION);
	printCurveChoices();
	lcd.blink(); // show cursor
	byte buttonID = NONE;
	while ( buttonID != SELECT ) // any button other than SELECT
	{
		buttonID = btn.waitForButton();
		btn.actionNavigate(buttonID, CURVE_CHOICE_DURATION,
						   &col, &row, 0, 0, 0, 1); // up/down choice
								// between default (A) and user
								// defined curve (B)
	}
	lcd.noBlink();
	return row; // Choice will either be top (Defaut)
		// or bottom row (User-Defined)
}
Exemplo n.º 3
0
void loop() {
	lcd.print("Minutes: ");
	lcd.setCursor(0,1);
	lcd.blink();
	while (selectmin == true) {
		lcd_key = read_LCD_buttons();
		switch (lcd_key) {
			case btnRIGHT: 
				break;
			case btnLEFT: 
				break;
			case btnUP: {
				minutes = minutes + 1;
				lcd.setCursor(0,1);
				lcd.print(minutes);
				break;
			}
			case btnDOWN: {
				if (minutes > 0) {
					minutes = minutes - 1;
					lcd.setCursor(0,1);
					lcd.print(minutes);
				}
				break;
			}
			case btnSELECT: {
				selectmin = false;
				break;
			}
			case btnNONE: 
				break;			
		}
		delay(200); 
	}
	lcd.clear(); 
	delay(500);
	lcd.print("Seconds: ");
	lcd.setCursor(0,1);
	lcd.blink();
	while (selectsec == true) {
		lcd_key = read_LCD_buttons();
		switch (lcd_key) {
			case btnRIGHT: 
				break;
			case btnLEFT: 
				break;
			case btnUP: {
				if (seconds == 59) {
					seconds = 0;
				} else {
				seconds = seconds + 1;
				}
				lcd.setCursor(0,1);
				lcd.print(seconds);
				break;
			}
			case btnDOWN: {
				if (seconds > 0) {
					seconds = seconds - 1;
				} else if (seconds == 0) {
					seconds = 59;
				}
				lcd.setCursor(0,1);
				lcd.print(seconds);
				}
				break;
			}
			case btnSELECT: {
				selectsec = false;
				break;
			}
			case btnNONE: 
				break;			
		}
	}