Introduction
We set a pin as input or output to control if it reads signals or sends signals in a circuit.
DDRx |= (1 << PINx); // Set pin as output DDRx &= ~(1 << PINx); // Set pin as input
DDRB |= (1 << 3); // Set pin 3 of port B as output
DDRC &= ~(1 << 2); // Set pin 2 of port C as input
DDRD |= (1 << 0); // Set pin 0 of port D as output DDRD &= ~(1 << 1); // Set pin 1 of port D as input
#include <avr/io.h> int main(void) { // Set pin 5 of port B as output DDRB |= (1 << 5); // Set pin 4 of port B as input DDRB &= ~(1 << 4); while (1) { // Main loop does nothing } return 0; }
DDRC |= (1 << 2); // Line 1 DDRC &= ~(1 << 2); // Line 2
DDRD |= (0 << 5);
Pass the test and this pattern moves unknown