void setup() 
{
  //to prevent fuse from blowing
  motor.speed(leftWheelPin, 0)  ;
  motor.speed(rightWheelPin, 0)  ;
  
  //attach driving servo
  RCServo1.attach(RCServo1Output) ;
  RCServo1.write(neutral)  ; 
  
  //set ports to inputs
  portMode(0, INPUT) ;      	 
  portMode(1, INPUT) ;
  
  Serial.begin(9600);
  
    while(1){
    delay(50);
    while( !(stopbutton()) ){
      delay(50);
        LCD.setCursor(0,0);  LCD.clear();  LCD.home() ;
        LCD.print("kP");
        LCD.print(" ");
        LCD.print(kP);
        kP = knob(knob_one)/10; 
        LCD.print(" ");
        LCD.setCursor(0,1);
        LCD.print("kD");
        LCD.print(" ");
        LCD.print(kD);
        kD = knob(knob_two)/10;
        if (startbutton())
        {
          goto loopstart;
        }
    }
    delay(50);
    while( !(stopbutton())) { 
        delay(50);
        LCD.setCursor(0,0);  LCD.clear();  LCD.home() ;
        LCD.print("motorSpeed");
        LCD.print(" ");
        LCD.print(motorSpeed);
        motorSpeed = knob(knob_two);
        LCD.setCursor(0,1);
        LCD.print("Adjust");
        LCD.print(" ");
        LCD.print(knob(knob_one));
        motorAdjustment = knob(knob_one)/512;
        if (startbutton())
        {
          goto loopstart;
        }
    }
    
  }
        loopstart: ;
}
Exemple #2
0
void setup() 
{
    portMode(0, INPUT);
  
    LCD.clear();
    LCD.home();
    LCD.setCursor(0,0); LCD.print("Wave Frequency");
    LCD.setCursor(0,1); LCD.print("Press Start");
    while ( !(startbutton()) ) ;
}
Exemple #3
0
void setup() 
{
  portMode(0, INPUT);
  
  LCD.clear();
  LCD.home();
  LCD.setCursor(0,0); LCD.print("Hello World!");
  LCD.setCursor(0,1); LCD.print("Press Start");
  while ( !(startbutton()) ) ;
}
Exemple #4
0
void UpdateMenu()
{
	if (startbutton())
	{
		ChangeMenuState();
		delay(mMenuDelay);
	}
	RefreshCurSelection();

	UpdateDisplay();

	delay(mUpdateDelay);
}
Exemple #5
0
// Determines if the start button is being pressed.
// Optional: Debounces the button for the specified number of milliseconds
bool StartButton(int debounceTime = 80)
{
	if(!startbutton()) return false;
	delay(debounceTime);
	return startbutton();
}
Exemple #6
0
void loop()
{
  RCServo1.write(angle_neutral);
  collector_switchState = LOW;


    if (timeTicker == 50) {
        timeTicker = 0; 

      if (startbutton() && !startButtonState) {
                if (menuState == 3) {
                    menuState = 1;
                } else {
                    menuState++;
                }
                editable = false;
                startButtonState = true;
                delay(500);
            } else if (stopbutton() && !stopButtonState) {
                editable = true;
                stopButtonState = true;
            } else {
                stopButtonState = false;
                startButtonState = false;
            }
            LCD.clear();    
    

            // Menu System
                // 1:   

            switch (menuState) {    

                case 1:
                    LCD.print("Rest: ");
                    userSet = (int)(knob(6) * 180.0/1024.0);
                    if (userSet != angle_neutral && editable){
                        angle_neutral = userSet;
                    }
                    LCD.print(angle_neutral, DEC);  

                    LCD.setCursor(0,1); 

                    LCD.print("Collect?: Y/N  ");
                    userSet = (int)(knob(7) * 2.0/1024.0);
                    if(userSet != collect_status && editable){
                        collect_status = userSet;
                    }
                    LCD.print(collect_status, DEC); 

                    break;
              
                case 2:
                    LCD.print("Min: ");
                    userSet = (int)(knob(6) * 180.0/1024.0);
                    if(userSet != angle_min && editable){
                        angle_min = userSet;
                    }
                    LCD.print(angle_min, DEC);  

                    LCD.setCursor(0,1); 

                    LCD.print("Max: ");
                    userSet = (int)(knob(7) * 180.0/1024.0);
                    if(userSet != angle_max && editable){
                        angle_max = userSet;
                    }
                    LCD.print(angle_max, DEC);  

                    break;

                case 3:
                    LCD.print("TestRange: ");
                    userSet = 1.5*(int)(knob(6) * 180.0/1024.0);
                    if(userSet != angle_neutral && editable){
                        if (userSet >= 180){
                            angle_neutral = 180;
                        } else{
                            angle_neutral = userSet;
                        }
                    }
                    LCD.print(angle_neutral, DEC);

                    break;
                }   

    }


    if(collect_status == 1){
        collector_switchState = digitalRead(COLLECTOR_SWITCHPIN);   

        if(collector_switchState){
            RCServo1.write(angle_min);
            delay(200);
            RCServo0.write(angle_max);
            delay(200);
            pusher_activate();
            RCServo1.write(angle_neutral);
            collector_switchState = false;
        }   

    }

    timeTicker++;

}