Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6858303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:08:28+00:00 2026-05-27T02:08:28+00:00

How do I automate my robot I have a robot that is being controlled

  • 0

How do I automate my robot

I have a robot that is being controlled by key presses, if the key pressed equals a certain key, either up, down, left or right are registered and the robot will move. I also have the following methods to play around with:

  • int getSpeed();
  • void forwardGear();
  • void reverseGear();
    isTouchingWall(); Booleon

I basically want to say if speed equals 0 than I can shift up a gear and then accelerate.
And if the robot isTouchingWall() turn around or something.
I’m not sure how I can use the reverseGear() method yet.

This is my code so far:

public void keyPressed(KeyEvent e) {

switch (e.getKeyCode()) {
                case 37:  
                    super.turnLeft();
                    break;
                case 38:  
                    super.accelerate();
                    break;
                case 39:  
                    super.turnRight(); 
                break;
                case 40: 
                    super.decelerate();
                    break;
        }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:08:29+00:00Added an answer on May 27, 2026 at 2:08 am

    You can use another Key for reverseGear() for example ‘r’

    public void keyPressed(KeyEvent e) {
    
    switch (e.getKeyCode()) {
                    case 37:  
                        super.turnLeft();
                        break;
                    case 38:  
                        super.accelerate();
                        break;
                    case 39:  
                        super.turnRight(); 
                    break;
                    case 40: 
                        super.decelerate();
                        break;
                    case 82: 
                        super.reverseGear();//key r
                        break;
    
            }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The more and more advanced compilers, languages, and frameworks we have that either automate
I'm trying to automate some processes using Robot and it seems certain keycodes (only
I have a program which uses the Robot class in Java to automate a
I need to automate a process involving a website that is using a login
I have a windows application which has a complex GUI that I would like
I have a ViewController that manages a view full of controls, including UITextView s,
I have a piece of mature geospatial software that has recently had areas rewritten
I have a WPF UserControl that I'd like to inject dependencies into. What's the
I'm working on a small fun projects that builds a robot. We as the
I have 2 Document objects with documents that contain similiar XML's. For example: <tt:root

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.