Learn Factory-io-scripting - 10 Code Examples & CST Typing Practice Test
Factory I/O scripting refers to automating, controlling, and interacting with Factory I/O simulations using C# (or Python via API). It enables programmatic control of virtual industrial environments, input/output devices, and process logic, allowing testing and validation of PLC programs without physical hardware.
View all 10 Factory-io-scripting code examples →
Learn FACTORY-IO-SCRIPTING with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
Factory I/O Toggle Sensor Output
void Update() {
bool sensor = IOLink.GetBool("Sensor1");
IOLink.SetBool("Actuator1", sensor);
}
Read a digital sensor and toggle an output actuator.
Factory I/O Timed Conveyor Start
float timer = 0;
bool running = false;
void Update() {
if (IOLink.GetBool("EntrySensor") && !running) {
running = true;
timer = 3f;
IOLink.SetBool("Conveyor", true);
}
if (running) {
timer -= Time.deltaTime;
if (timer <= 0) {
IOLink.SetBool("Conveyor", false);
running = false;
}
}
}
Start the conveyor for 3 seconds whenever a sensor triggers.
Factory I/O Counter for Produced Items
int count = 0;
void Update() {
if (IOLink.GetBool("OpticSensor")) {
count++;
Debug.Log("Items: " + count);
}
}
Count items detected by an optical sensor.
Factory I/O Sorting with Two Actuators
void Update() {
int color = IOLink.GetInt("ColorID");
if (color == 1) {
IOLink.SetBool("PusherLeft", true);
}
else if (color == 2) {
IOLink.SetBool("PusherRight", true);
}
else {
IOLink.SetBool("PusherLeft", false);
IOLink.SetBool("PusherRight", false);
}
}
Sort items left or right based on color sensor.
Factory I/O Emergency Stop Logic
void Update() {
if (IOLink.GetBool("EmergencyStop")) {
IOLink.SetBool("Motor1", false);
IOLink.SetBool("Motor2", false);
IOLink.SetBool("Conveyor", false);
}
}
Stop all outputs if an emergency switch is pressed.
Factory I/O Light Stack Indicator
void Update() {
bool idle = IOLink.GetBool("IdleState");
bool running = IOLink.GetBool("RunState");
bool fault = IOLink.GetBool("FaultState");
IOLink.SetBool("LightGreen", running);
IOLink.SetBool("LightYellow", idle);
IOLink.SetBool("LightRed", fault);
}
Control a stack light (red/yellow/green) based on machine states.
Factory I/O Palletizer Robot Cycle
void Update() {
if (IOLink.GetBool("BoxArrived")) {
IOLink.SetBool("RobotGrab", true);
IOLink.SetBool("RobotMoveToStack", true);
}
if (IOLink.GetBool("RobotAtStack")) {
IOLink.SetBool("RobotGrab", false);
IOLink.SetBool("RobotReturn", true);
}
}
Automate a simple pick-and-place robot cycle.
Factory I/O Variable Speed Conveyor
void Update() {
float speed = IOLink.GetFloat("SpeedDial");
IOLink.SetFloat("ConveyorSpeed", speed);
}
Control conveyor speed dynamically from an analog input.
Factory I/O Fault Reset Handling
int itemCount = 0;
void Update() {
if (IOLink.GetBool("ResetButton")) {
itemCount = 0;
IOLink.SetBool("Actuator1", false);
IOLink.SetBool("Actuator2", false);
}
}
Reset actuators and counters when a reset button is pressed.
Factory I/O Multi-Sensor Condition Check
void Update() {
bool s1 = IOLink.GetBool("Sensor1");
bool s2 = IOLink.GetBool("Sensor2");
bool s3 = IOLink.GetBool("Sensor3");
bool fault = s1 || s2 || s3;
IOLink.SetBool("Alarm", fault);
}
Trigger an alarm if any sensor in a group detects an issue.
Frequently Asked Questions about Factory-io-scripting
What is Factory-io-scripting?
Factory I/O scripting refers to automating, controlling, and interacting with Factory I/O simulations using C# (or Python via API). It enables programmatic control of virtual industrial environments, input/output devices, and process logic, allowing testing and validation of PLC programs without physical hardware.
What are the primary use cases for Factory-io-scripting?
Simulating industrial processes for PLC training. Testing and debugging automation logic. Automated control of virtual sensors and actuators. Scenario-based training for operators and engineers. Integration with external control systems for prototyping
What are the strengths of Factory-io-scripting?
Safe and cost-effective testing of industrial processes. Rapid prototyping and debugging of PLC logic. Supports educational labs and hands-on learning. Visual, interactive, and immersive training experience. Extensible via scripting for complex scenarios
What are the limitations of Factory-io-scripting?
Requires Factory I/O license. Limited to simulated environment; not a full PLC replacement. Advanced physics or large-scale plants may impact performance. Scripting API is less extensive than full programming platforms. Integration may require knowledge of industrial protocols
How can I practice Factory-io-scripting typing speed?
CodeSpeedTest offers 10+ real Factory-io-scripting code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.