/* * HtM_Sensors.c * * Created: 11/21/2017 9:11:11 * Author : Casey Evans */ /* Original template from the Tinysaur project */ /* Adapted basic functional code from Neil's code */ #include #include // ==================================== // ATtiny // 44A // +--------+ // --+Vcc GND+--------- // LED - PB0 --+ +-- PA0 // LED - PB1 --+ +-- PA1 // LED - PB3 --+ +-- PA2 // LED - PB2 --+ +-- PA3 // LED - PA7 --+ +-- PA4 // LED - PA6 --+ +-- PA5 // +--------+ // ==================================== // Define the I/O port to be used for the sensors. // The sensors each use one or two ports and I will define them accordingly. // That way they will line up properly on the headers. #define LED_PORT PA7 #define BUTTON_PORT PB2 #define BUTTON_IN (1 << PB2) int main(void) { // Set port as output // The DDRA/B is the data direction register // The code below // - shifts the "1" on left to the desired position // - does bitwise "OR" with the value in the port register. DDRA |= (1 << LED_PORT); // Sets port as input DDRB &= ~(1 << BUTTON_PORT); // Engages pull-up resistor PORTB |= (1 << BUTTON_PORT); while (1) { // wait for button down // while (0 != (PINB & BUTTON_IN)) ; PORTA |= (1 << LED_PORT); // // wait for button up // while (0 == (PINB & BUTTON_IN)) ; PORTA &= ~(1 << LED_PORT); } return (0); }