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
Circuit
Note*
Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the Controllino permanently.
Code
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 delay(del); PORTD = PORTD & B11101111; //Set LOW delay(del); } /* //Digital output 21 PORTD = PORTD | B00100000; delay(del); PORTD = PORTD & B11011111; delay(del); //Digital output 22 PORTD = PORTD | B01000000; delay(del); PORTD = PORTD & B10111111; delay(del); //Digital output 23 PORTD = PORTD | B10000000; delay(del); PORTD = PORTD & B01111111; PORTJ = PORTJ | B00010000; delay(del); PORTJ = PORTJ & B11101111; delay(del); 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 */