Author Archives: sw0rdm4n

Switch Based on Contact (SPST, SPDT, DPST, DPDT)

by : Antonius (@sw0rdm4n)

Understanding switch types is very important when developing an electronic circuit. Below is just several example of switches (not a complete list) classified by pole(s) and throw(s).



SPST stands for single pole single throw.  Pole means how many circuit(s), a switch can control. Throw means how many conducting position for a switch. This one is the basic form of a switch, where this switch has only 2 terminals. When the throw is closed means current can flow, meanwhile when the throw is open, current is break.

In order to understand more, let’s take a look here (sorry for bad drawing skills)



For example here we have a gate when the gate is open, means the electrical flow is break.


When the gate is closed means current can flow and the lamp is on. Since this only has 1 circuit (the lamp in this case), and only 1 throw (only 1 conducting position that will turn the light on, so this switch is called SPST).

Real life example:




SPDT stands for single pole double throw. As we can see from the symbol, a single pole double throw switch has 3 terminals.

In order to understand more, let’s take look at below example:


This one is similar to knife switch model, where the condition is open (current can not flow). The throw can be connected whether on right or left terminal.



Real life example




DPST stands for double pole single throw.

In order to understand about double pole single throw, take a look on below example.


in dpst , the throw only have one possible conducting, meanwhile it has 2 separate poles.


When the condition is closed the current can flow to light both 2 circuits. The while lines are any conducting materials.



DPDT stands for double pole double throw. This one has 2 poles and 2 throws. This one has 6 terminal(s).

Check out below example:



Real life example:




I hope this guide can be a light for those who wanted to understand more about switching in order to do the “Art of controlling the electron”.




H-Bridge Circuit Control Using Arduino and BananaPi

by : Antonius (@sw0rdm4n)

H-bridge is an electronic circuit which allow you to reverse the flow of electron in either direction.
To control a h-bridge circuit here, we’ll be using an arduino mega 2560 and arduino ethernet shield (that suitable for arduino mega 2560 with no electronic hacks). What we’re gonna do here is simply can be explained using below diagram :



The main purpose is to send some command(s) such as : forward / backward / left or right from banana pi to arduino mega. Then arduino mega will receives the command over ethernet and apply the suitable voltage over it’s pin(s) for h-bridge. The h-bridge then will apply suitable load for those 2 motor dc(s).

Communication Between Arduino and Banana PI or Raspberry PI or beagle bone to arduino can be accomplished using several method(s) such as using logic level converter ( or cape (for beagle bone) or maybe you can use arduino wifi shield and plug some wireless usb adapter to credit card size board. Within this example, we’ll be using ethernet to communicate between arduino and banana pi. Why use ethernet shield ? the programming will be easier, what you need is a knowledge on socket programming.

Hardware Requirements:

– 1 banana pi or raspberry pi or another credit card size board with linux os installed

– 1 arduino mega 2560

– 1 ethernet shield for arduino mega 2560

– 1 half size breadboard

– some jumper wire(s)

– 1 sn75441one or l293dne (h-bridge ic)

– 2 motor dc

Step 1 . Prepare H-Bridge circuit

Before making h-bridge circuit, plug the ethernet shield to arduino mega. So the pin(s) will be plugged on the ethernet shield.

In order to make h-bridge circuit, you can follow these tutorials:



Here comes the arduino mega 2560 with ethernet shield connected to h-bridge circuit :


Step 2. Prepare the code for arduino

Here comes the source code

/* arduino mega 2560 control receive command over ethernet and apply voltage to h-bridge circuit 
source code made by : Antonius (Sw0rdm4n)
#include <SPI.h>
#include <Ethernet.h> 

byte mac[] = { 0xDE, 0xA2, 0xDA, 0x0F, 0x17, 0xD9 }; 
IPAddress ip(10,0,0,3); 
IPAddress gateway(10,0,0,2); 
IPAddress subnet(255,128,0,0); 
EthernetServer server(23); 
boolean alreadyConnected = false;

/* h-bridge code for arduino Modified from */

int motorkanan_1 = 6;    
int motorkanan_2 = 7;   
int enablePin_1 = 9;   
int enablePin_2 = 8;   
int motorkiri_1 = 5;    
int motorkiri_2 = 4;    
int half_speed = 127;
int slow_sleep = 60;
int full_speed = 255;
int i = 0;
#define fwd 1
#define bwd 2
#define lft 3
#define rht 4
#define stp 5
int last_cmd = 0;

void setup() {
    Ethernet.begin(mac, ip);   
    Serial.println("\nrobot motoric started\n");
    pinMode(motorkanan_1, OUTPUT); 
    pinMode(motorkanan_2, OUTPUT); 
    pinMode(motorkiri_1, OUTPUT); 
    pinMode(motorkiri_2, OUTPUT); 
    digitalWrite(enablePin_1, HIGH); 
    digitalWrite(enablePin_2, HIGH); 
void tfwd()
      digitalWrite(motorkanan_1, LOW);  
      digitalWrite(motorkanan_2, HIGH);  
      digitalWrite(motorkiri_1, LOW);   
      digitalWrite(motorkiri_2, HIGH);  
void tstop()

    digitalWrite(motorkanan_1, LOW);  
    digitalWrite(motorkanan_2, LOW);
    digitalWrite(motorkiri_1, LOW);  
    digitalWrite(motorkiri_2, LOW);
void tback()
      digitalWrite(motorkanan_1, HIGH);   //right
      digitalWrite(motorkanan_2, LOW);
      digitalWrite(motorkiri_1, HIGH);   //left 
      digitalWrite(motorkiri_2, LOW);
void tleft()
      digitalWrite(motorkanan_1, HIGH);  
      digitalWrite(motorkanan_2, LOW);  
      digitalWrite(motorkiri_1, LOW);  
      digitalWrite(motorkiri_2, HIGH);
      last_cmd = 0; 
void tright()
      digitalWrite(motorkanan_1, LOW);  
      digitalWrite(motorkanan_2, HIGH);  
      digitalWrite(motorkiri_1, HIGH);   
      digitalWrite(motorkiri_2, LOW);
      last_cmd = 0;

void get_ethernet_cmd()
    char cmd;
    /* modified from arduino ethernet chat server */ 
    EthernetClient client = server.available();
    if (client) {
        if (!alreadyConnected) {
              Serial.print("\nReady !\n");
              client.println("motoric ready to receive command !"); 
              alreadyConnected = true;
        if (client.available() > 0) {
               Serial.print("reading from client");
               cmd =;
               Serial.print("\ngot command:");
               switch (cmd) {
                   case 'f':
                   last_cmd = fwd;
                   case 'b':
                   last_cmd = bwd;
                   case 's':
                   last_cmd = stp;
                   case 'l':
                   last_cmd = lft;
                   case 'r':
                   last_cmd = rht;               

void net_op()
   if (last_cmd == 0) {
   else {
      switch (last_cmd) {
        case fwd:
        case bwd:
        case stp:
        case lft:
        case rht:
void loop() {

Step 3. Plug rj45 to arduino and connect it to banana pi

Once you have done everything correctly, we can control h-bridge circuit using banana pi.
Based on above source, arduino ip address is at where it’s gateway is (our banana pi). From banana pi terminal what to do is simple:
ifconfig eth0 netmask up

Now, from banana pi terminal, we can send  some command(s) to make our 2 motor dc(s) move forward, backward, left or right.

From terminal, type :


Then we’ll be connected to arduino mega 2560

In order to make motor dc moves forward, type: f

In order to make motor dc moves backward, type: b

In order to make motor dc moves left, type: l

In order to make motor dc moves right, type: r

In order to make motor dc stop, type: s







Introducing Haxtronic – A Robotic Brain That Can Scan for Wireless Network Around

Introducing Haxtronic – A Robotic Brain for Scanning Wireless Network Around, this robotic brain is powered by kali linux and Banana PI. This robotic brain can be connected to arduino as motoric using various way such as using ethernet, power level shifter, etc.

Actually this robot can use aircrack-ng already. Currently programming for visual functionality for this robot using opencv.

Mathematic Algebras

Algebra is a method to simplify calculation, a method to reunite broken parts, a method to solve puzzles. Algebra skills are very important for an electronic engineer (or maybe for hackers) to solve any circuit problems related to mathematic. Not too much words, below is example of algebra problems and the problem solver:

Algebra Problem 1. simplify :

4a + 3b² – a + 2 = 38

Problem Solving:

4a + 3b² – a + 2 = 38

(4a – a) + 3b² = 38 – 2

3a + 3b² = 36

√3a + 3b = 6

Algebra Problem 2, find y :

5y+50 = 2 (3y + 10 )

Problem solving:

5y+50 = 2 (3y + 10 )

5y+50 = 6y + 20

5y +50 – 20 = 6y

5y + 30 = 6y

30 = 6y – 5y

y = 30

Example problem 3, find value of i:

2 = i + √3

Problem Solving:

2² = i² + 3

4 = i² + 3

i = 1

Example problem 4:

Simplify: 2x + 3(x + 10) = 55

Problem Solving

2x + 3x + 30 = 55

5x = (55-30)

5x = 25

x = 5


Basic Trigonemetric for Robotic Mechanical Joints

Trigonemetric is a branch of mathematic which frequently used in robotics where it’s commonly used in inverse kinematics of mechanical leg / joints, forward kinematics, etc. Trigonometric calculates about angles and sides of a triangle. In trigonemetric, there’s ratios for acute angles:

– sin = opposite  /  hypotenuse

– cos = adjacent / hypotenuse

– tan = opposite  / adjacent

– secant = hypotenuse / adjacent

– cosecant = hypotenuse / opposite

– cotangent = adjacent / opposite

For example here we have a triangle:


it’s known that adjacent’s length is 4 and hypotenuse’s length is 5. Based on phytagoras theorem:



So :

4²  + b² = 5²

16 + b² = 25

b = √9 = 3

So we got :

Sin R = b / c = 3 / 5, Cos R = a / c = 4 / 5, Tan R = b/a = 3/4, Secant R = c/a = 5/4, Cosecant R = c  / b =5/3, cotangent R = a/b = 4/3

Trigonometric on Equilateral Triangle

For example here, we have an equilateral triangle:


Actually that equilateral triangle can be divide into 2 area, something like this :


That equilateral triangle when divided into 2 areas, has each 30 degress for it’s top.

Let’s just give name for each angle on cartesius coordinate as x and y:


How to calculate sin x, cos x , tan x, sin y, cos y and tan y ?

Have a check on special table of trigonometry :


Since sin x is 30 degree = 1/2, where sin = opposite  /  hypotenuse, so sin x = b / c, we figure out that b = 1 and c = 2. To find a based on phytagoras theory:

c² = a² + b²

2² = a² + 1²

4 = a² +  1

a = √3

So cos x = adjacent / hypotenuse  = a / c = √3 / 2

tan x = opposite  / adjacent = b / a = 1/√3

The same goes for sin, cos and tan y.


Making an Electronic Torch – Schematic, PCB Version and Breadboard Version

by : Antonius (@sw0rdm4n)

Electronic Torch is an unique electronic circuit to learn about how electric flow through each components. Below is the electronic circuit:


Part Lists Based on Above Schematic

– 2 resistor 330 ohm or 320 ohm. (breadboard version can uses up to 3 resistors)

– 3 led

– 3 switch

– 1 Dioda in4001

How this works on PCB Version ?

Below is the electronic circuit logic flow :

– If switch is on,  the current will flow  through:

D1 (since it’s a dioda it will prevent reverse current) ->  switch ->  R1 -> led1 -> led2 -> ground

– If s1 is on,  the current will flow  through:

D1 -> S1 -> R1 -> led1 -> led2 -> ground.

– if s2 is on, the current will flow through:

D1 -> S2 -> R2 -> led 3 -> ground

Solder each component based on above schematic



– Clean your solder with sponge before soldering

– Before soldering drop some soldering tin on top of your solder

– Don’t use to much soldering tin

And here comes the pcb version of the torch :


Breadboard Version

We can also making breadboard version, vero board version, and so on. Here’s the breadboard version of this electronic torch with 3 resistor (1 resistor 330 ohm and 2 resistor 320 ohm).


To see how this circuit works, you can see this video: