CIKU + 2Amp Motor Driver Shield

Hi, this tutorial will show you how to build line following robot by using CIKU and 2Amp Motor Driver Shield.



1. CIKU (link).
2. 2Amp Motor Driver Shield (link).
3. Aluminium Robot Chassis Complete Set (link).
4. Auto-Calibrating Line Sensor (link).
5. 2 units of 3.7V 1100mAh Li-Ion Battery (link).
6. 2×18650 Battery Holder (link).
7. Dual 18650 Li-Ion Battery Charger (link).
8. DC Jack(Male) to DG126 Converter (link).
9. Jumper wire to connect from DC motor to 2Amp Motor Driver Shield.
*You can refer here for how to mount CIKU, DC motor and line sensor to robot base.
**Total price ~ RM302.50




Please refer to “Getting Started with CIKU” tutorial.


Below is a list for SHIELD-2AMOTOR function that you can used with CIKU. You also can refer to the Shield2AMotor.h (under CIKU.X folder) for detail.

// Shield2AMotor_begin
// sensor: LSS05_ENABLE or LSS05_DISABLE
void Shield2AMotor_begin(BOOL mode, BOOL sensor);
// Shield2AMotor_control
// motor1Speed: -100 to 100
// motor2Speed: -100 to 100
// *minus value will have different direction from positive value
void Shield2AMotor_control(INT16 motor1Speed, INT16 motor2Speed);
// Shield2AMotor_readLSS05
// return status for every IR sensor
// bit 1 represent 'detect line', and vice versa.
// e.g. 0b00100 means middle IR sensor detect black line
// e.g. 0b10000 means most left IR sensor detect black line
// e.g. 0b00001 means most right IR sensor detect black line (next to Cal. push button)
BYTE Shield2AMotor_readLSS05(void);

For more library reference, you can refer here.


This example code shows related function that you can used with 2Amp Motor Driver Shield. You also can see this code under User-LineFollowingRobot.cfile (under CIKU.X folder).
*SW on CIKU board can be used as user program too. Please do refer on the following code. So, to run the robot, user need to press the SW first.

#include "Arduino.h"
#include "Shield2AMotor.h"
void setup()
pinMode(SW, INPUT); // SW on CIKU board
pinMode(LED, OUTPUT); // LED on CIKU board
while(digitalRead(SW) == HIGH); // Wait SW button to be pressed
digitalWrite(LED, HIGH); // Turn ON LED
void loop()
BYTE lineSensor = Shield2AMotor_readLSS05();
if(lineSensor == 0b00100)
Shield2AMotor_control(80, 80); // Robot move straight forward
else if(lineSensor == 0b01100)
Shield2AMotor_control(50, 80); // Motor1 speed = 50%, motor2 speed = 80%
else if(lineSensor == 0b00110)
Shield2AMotor_control(80, 50); // Motor1 speed = 80%, motor2 speed = 50%
else if(lineSensor == 0b01000)
Shield2AMotor_control(30, 80); // Motor1 speed = 30%, motor2 speed = 80%
else if(lineSensor == 0b00010)
Shield2AMotor_control(80, 30); // Motor1 speed = 80%, motor2 speed = 30%
else if(lineSensor == 0b11000)
Shield2AMotor_control(10, 80); // Motor1 speed = 10%, motor2 speed = 80%
else if(lineSensor == 0b00011)
Shield2AMotor_control(80, 10); // Motor1 speed = 80%, motor2 speed = 10%
else if(lineSensor == 0b10000)
Shield2AMotor_control(0, 80); // Motor1 stop, motor2 speed = 80%
else if(lineSensor == 0b00001)
Shield2AMotor_control(80, 0); // Motor1 speed = 80%, motor2 stop


If you want to compile User-LineFollowingRobot.c, under MPLAB X IDE, first please remove the User-Template.c (CIKU – Source Files – user). Right click on User-Template.c and select Remove From Project. Then, right click on user folder (CIKU – Source Files), choose Add Existing Item…, open User-LineFollowingRobot.c, and proceed with Build Project.


Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

DIY Interactive Robot Using REKA:BIT With Micro:bit
BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
DIY Automated Vacuum Cleaner Using REKA:BIT With Micro:bit
Rainbow Spark in Mini House using Maker Uno.
Tutorials of Cytron Technologies Scroll to Top