#include <16F84A.h> #FUSES NOWDT //No Watch Dog Timer #use delay(crystal=4MHz) #define boolean short int #define LED1 PIN_B1 #define LED2 PIN_B2 #define LED3 PIN_B4 #define LED4 PIN_B6 #define LED5 PIN_B5 #define LED6 PIN_B7 #define DELAY 1000 void test_led(){ output_high(LED1); output_high(LED2); output_high(LED3); output_high(LED4); output_high(LED5); output_high(LED6); delay_ms(900); output_low(LED1); output_low(LED2); output_low(LED3); output_low(LED4); output_low(LED5); output_low(LED6); } void clear_led(){ output_low(LED1); output_low(LED2); output_low(LED3); output_low(LED4); output_low(LED5); output_low(LED6); } void gate_pin_state(unsigned int Pin, boolean s){ if (s == 1) output_high(Pin); if (s == 0) output_low(Pin); } ////bramki short int and_gate(short int a, short int b){ gate_pin_state(LED1, a); gate_pin_state(LED2, b); short int c = 0; if (a == 1 && b == 1) c = 1; gate_pin_state(LED4,c); return c; } short int not_gate(short int a){ gate_pin_state(LED3, a); short int c = 0; if (a == 1) c = 0; if (a == 0) c = 1; gate_pin_state(LED5,c); return c; } short int or_gate(short int a, short int b){ //gate_pin_state(LED4, a); //gate_pin_state(LED5, b); short int c = 0; if (a == 1) c = 1; if (b == 1) c = 1; gate_pin_state(LED6,c); return c; } void main() { delay_ms(900); test_led(); delay_ms(900); short int a[] = {1,0,1,0,1,0,1,0}; short int b[] = {1,1,0,0,1,1,0,0}; short int c[] = {1,1,1,1,0,0,0,0}; while(true) { int x; for(x=0;x<8;x++){ delay_ms(DELAY); clear_led(); short int an = and_gate(a[x],b[x]); short int no = not_gate(c[x]); or_gate(an,no); delay_ms(DELAY); } } }