Technical specifications
- Supply voltage: 3–5 V
- Maximum current: <1 mA
Description
The impact sensor detects knocks and vibration.
It uses a metal housing with a small metal spring inside. In its normal state, the spring does not touch the housing. An impact or vibration makes the spring move and touch the cylinder wall, closing the circuit.
The sensor is very sensitive and may trigger even under slight acceleration, including when motors start or while the robot is moving steadily. Take this into account when designing your project.
Use
Connection
The sensor uses a standard 3-pin connector and connects to any IN port on the Trackduino controller.
Programming
The required block is called “impact” and is in the “Sensors” block group.
| Block and generated function | Description |
|---|---|
![]() bool shock(int port) | Returns true when the sensor is triggered.Argument: int port — the port the sensor is connected to. |
Project example
Alert guard
Generated code:
void setup()
{
pinMode( OUT1 , OUTPUT );
pinMode( OUT2 , OUTPUT );
}
void loop()
{
if (shock(IN1))
{
tone(OUT3, 1000);
led ( OUT1 , HIGH );
led ( OUT2 , LOW );
delay( 1000 );
led ( OUT1 , LOW );
led ( OUT2 , HIGH );
delay( 1000 );
}
else
{
led ( OUT1 , LOW );
led ( OUT2 , LOW );
}
}

