The Hedgehog IDE is allows you to create and run your own programs easily, without installing extra software or creating accounts first. We respect your privacy and your data, so we don't require any of your data unless absolutely needed - that is, basically, the code you write and nothing else.
Creating a project
A software project contains files that work together to create a program. Creating one is the first thing you will have to do to get started. In your project list, click on the "+" icon and choose a name. After you created the project, click on it to open it.
After opening the project, right click the project root to create a file in it. In this example, let's choose "New Blockly File" – Blockly allows the visual creation of programs. After naming the file, make sure it's shown in the project tree, and open it by double-clicking. You will see a Blockly workspace where you can create your program.
Controlling a simulated robot with Blockly
Before you start adding blocks to your program, let's look at the simulator. Click on the X,Y,Z axis icon above the project tree to open it in a new tab, then drag that tab to the side to see Blockly and the simulator at the same time.
The Simulator (and the console, which is opened with the second button above the project tree) opens automatically when a program gives commands to the robot (or outputs text, respectively) if it is not already open.
Blockly commands are organized by categories:
- Drive lets you drive the robot by starting or stopping two motors at the same time. Motors can use speeds between -100 and +100. The simulated robot's left wheel is motor 0, the right wheel motor 1.
- Motors lets you control motors individually.
- Servos lets you control servos. Servo positions are between 0 and 1000. The simulated robot does not yet have any servos, though. Stay tuned!
- Sensors lets you observe the simulated environment. Sensor values are between 0 and 4095. The simulated robot has five sensors at its front:
- Four line sensors that can detect the black lines on the ground; these are sensors 0 to 3, from right to left. The sensor value is high when a line is detected.
- One bump sensor that is almost as wide as the robot front; this is sensor 8. The sensor value is low when a collision is detected.
- The other categories contain general programming constructs, such as conditionals and loops.
Now let's try out a simple program:
Create this program in your project, then click the green "Play" button; you will see the robot driving to the other side of the simulation and stopping at the wall. In detail, what happened is the following:
- The first block let the robot move forward.
- The next block is a loop, running while the sensor on digital port 8 has a high value. In other words, the loop repeats until a collision is detected.
- Inside the loop, the program simply sleeps. That means that the robot will continue moving as long as there was no collision.
- After the loop, i.e. as soon as there was a collision, the robot is stopped. This is the last command, so the program is finished.