ApelPro

testIC0

Mar 7th, 2021
696
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _2OUT 2
  2. #define _2A 4
  3. #define _2B 3
  4. #define _1OUT 5
  5. #define _1A 7
  6. #define _1B 6
  7.  
  8. #define OR2A 10
  9. #define OR2B 9
  10. #define OR2OUT 8
  11.  
  12. void setup()
  13. {
  14.   pinMode(_2A, OUTPUT);
  15.   pinMode(_2B, OUTPUT );
  16.   pinMode(_2OUT, INPUT );
  17.   pinMode( OR2OUT, INPUT );
  18.   pinMode( OR2A, OUTPUT );
  19.   pinMode( OR2B, OUTPUT );
  20.  
  21.   Serial.begin( 115200 );
  22. }
  23.  
  24. void print( int a, int b, int c, int d ) {
  25.   digitalWrite( _2A, a );
  26.   digitalWrite( _2B, b );
  27.   digitalWrite( _1A, c );
  28.   digitalWrite( _1B, d );
  29.   digitalWrite( OR2A, digitalRead( _2OUT ) );
  30.   digitalWrite( OR2B, digitalRead( _1OUT ) );
  31.  
  32.   Serial.print( a );
  33.   Serial.print( b );
  34.   Serial.print( c );
  35.   Serial.print( d );
  36.   Serial.print( " => " );
  37.   Serial.print( digitalRead( _2OUT ) );
  38.   Serial.println( digitalRead( _1OUT ) );
  39.   Serial.print( "OR: " );
  40.   Serial.println( digitalRead( OR2OUT ) );
  41. }
  42.  
  43. void logic( int* var  ) {
  44.     *var = !(*var);
  45.     /*
  46.      * int* var;
  47.      * var = 0; => var mutasson a 0-s címre
  48.      * var = NULL;
  49.      * *var = 0 => var által tárolt címen helyezzen el 0-t
  50.      ** var-nak előtte értéket kell kapnia (nem lehet 0)
  51.      */
  52. }
  53.  
  54. int a = 0, b = 0, c = 0, d = 0;
  55.  
  56. void loop()
  57. {  
  58.   logic( &a );
  59.   print( a, b, c, d );
  60.   delay( 1000 );
  61.  
  62.   logic( &b );
  63.   print( a, b, c, d );
  64.   delay( 1000 );
  65.  
  66.  
  67.   logic( &c );
  68.   print( a, b, c, d );
  69.   delay( 1000 );
  70.  
  71.  
  72.   logic( &d );
  73.   print( a, b, c, d );
  74.   delay( 1000 );
  75. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×