Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Optocouplers on the hexabusplug
Clone this wiki locally
Simple output circuit switching an LED
- Set pin direction to output, e.g.
DDRA |= (1<<PA0);
- Setting pin in port register to HIGH will turn on the LED; setting it to LOW will turn it off.
PORTA |= (1<<PA0); //Turn LED on
PORTA &= ~(1<<PA0); //Turn LED off
Simple input circuit
- Activate internal pullup or add an external pullup to the circuit!
PORTA |= (1<<PA1);
- If the pin bit in PINA is set, the switch is open, if it is clear the switch is closed.