GAVJ8

        хватит мечтать, начинай кодить

        яндекс.директ

Выходы на реле (PD6, PD7 : PB6)
-------------------------------

`  #include <avr/io.h>
`  #include <util/delay.h>
`
`  #define F_CPU  1000000
`
`  #define SEG1_LATCH   PB0
`  #define SEG2_LATCH   PB1
`  #define POWER_LATCH  PB6
`  #define LED_LATCH    PB7
`
`  #define PORT_ON( port, pin)  port |= (1<<pin)
`  #define PORT_OFF( port, pin) port &= ~(1<<pin)
`
`  void init() {
`    DDRD = 0xff;
`    PORTD = 0xff;
`    DDRB = 0xc3;
`
`    PORTB |= (1<<SEG1_LATCH);
`    PORTB &= ~(1<<SEG1_LATCH);
`    PORTB |= (1<<SEG2_LATCH);
`    PORTB &= ~(1<<SEG2_LATCH);
`    PORTB |= (1<<POWER_LATCH);
`    PORTB &= ~(1<<POWER_LATCH);
`    PORTB |= (1<<LED_LATCH);
`    PORTB &= ~(1<<LED_LATCH);
`  }
`
`  int main(void)
`  {
`    int j = 0xdf;
`
`    init();
`
`    while(1) {
`      # 1101 1111 Relay in the corner of the board
`      # 1011 1111 Relay in the middle of the board
`      if (j != 0xdf) j=0xdf; else j=0xbf;
`      PORTD = ~j;
`      PORTB = 0x40;
`      PORTB = 0;
`
`      _delay_ms(1000);
`    }
`  }
`