< Back

Controllino MEGA has 24 High Side digital outputs available. The first 20 outputs we can control using the standard Arduino functions (e.g. digitalWrite and analogWrite), but for D20-D23 digital outputs we have to know how to use PORT manipulation on ATmega2560. On the connection picture we can see that there are no Arduino pins assigned to these outputs.

To see more about PORT manipulation please clickĀ here.

Hardware Required

  • Controllino MEGA
  • 12/24V DC Power supply


Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the Controllino permanently.


Controllino MEGA

void setup() 
 DDRD = DDRD | B01110000; //Set the ports PD4, PD5, PD6 as outputs
 DDRJ = DDRJ | B00010000; //Set the port PJ4 as output

void loop() {
 int del = 100;
 //Digital output 20
 PORTD = PORTD | B00010000; //Set HIGH
 PORTD = PORTD & B11101111; //Set LOW


//Digital output 21
 PORTD = PORTD | B00100000;
 PORTD = PORTD & B11011111;

//Digital output 22
 PORTD = PORTD | B01000000;
 PORTD = PORTD & B10111111;

//Digital output 23
 PORTD = PORTD | B10000000;
 PORTD = PORTD & B01111111;
 PORTJ = PORTJ | B00010000;
 PORTJ = PORTJ & B11101111;

 PORTD = PORTD | B01110000; // sets Digital Outputs 20,21,22 in one shot to HIGH
                            // -> turns the LEDs ON
 PORTJ = PORTJ | B00010000; // sets Digital Output 23 in one shot to HIGH 
                            // -> turns the LED ON

 PORTD = PORTD & B10001111; // sets Digital Outputs 20,21,22 in one shot to LOW 
                            // -> turns the LEDs OFF
 PORTJ = PORTJ & B11101111; // sets Digital Output 23 in one shot to LOW
                            // -> turns the LED OFF


This is a paragraph.It is justify aligned. It gets really mad when people associate it with Justin Timberlake. Typically, justified is pretty straight laced. It likes everything to be in its place and not all cattywampus like the rest of the aligns. I am not saying that makes it better than the rest of the aligns, but it does tend to put off more of an elitist attitude.