Gatekeeper Challenge Mission Banner - Image 1
Mission Mode 3

The Gatekeeper's Challenge: Servo Control

STORY

In a newly developed subdivision, a group of young engineering students notice long queues and wasted energy in the manual car gate system. They decide to design a sustainable automated car entrance system using servo motors and TRIOE.

Automated Gate Challenge

Gate System Status

GATE
SERVO
LED
Mission Icon

Mission Objectives

0/7

Build a simple automatic gate that opens when you press a button, then closes by itself!

Connect Servo Motor to Pin 9
Setup Button (Pin 2) and LED (Pin 13)
Read Button Press in Loop
Move Servo to Open (90°) and Close (0°)
Control LED and Print Messages
Select TRIOE ESP32S3 Dev Module
Select COM7 Port
Code Editor Icon

Loading...
Arduino Reference Icon

Arduino Reference

Servo Motor Commands

#include <Servo.h>

Include Servo library for servo motor control

Servo gateServo;

Create servo object to control servo motor

gateServo.attach(servoPin)

Attach servo to specified pin (usually pin 9)

gateServo.write(angle)

Move servo to specific angle (0-180 degrees)

Button & Digital Input

pinMode(2, INPUT_PULLUP)

Set button pin with internal pull-up resistor

digitalRead(2)

Read button state (HIGH when not pressed, LOW when pressed)

Functions & Movement

for (int pos = 0; pos <= 90; pos++)

Loop to move servo from 0 to 90 degrees

delay(100)

Small delay for smooth servo movement

Serial Monitor Icon

Serial Monitor

Arduino IDE Serial Monitor - TRIOE Board Connected to COM3 at 9600 baud Gate Control System Status: Waiting for initialization... Servo Motor Status: Not attached Button Status: Not configured Press "Verify Code" to compile and check your sketch.
Gatekeeper Challenge Mission