Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. #include <Wire.h>
  2.  
  3. const int tlacitko1 = 2;
  4. const int tlacitko2 = 3;
  5.  
  6. int stavTlacitka1;
  7. int stavTlacitka2;
  8.  
  9. void setup()
  10. {
  11.   Serial.begin(9600);
  12.   Wire.begin();
  13.   pinMode(tlacitko1, INPUT);
  14.   pinMode(tlacitko2, INPUT);
  15. }
  16.  
  17. void loop()
  18. {
  19.  stavTlacitka1 = digitalRead(tlacitko1);
  20.  stavTlacitka2 = digitalRead(tlacitko2);
  21.  
  22.  if (stavTlacitka1 == HIGH) {
  23.  
  24.   Wire.beginTransmission(1);
  25.   delay(100);
  26.   Wire.write('a');
  27.   delay(100);
  28.   Wire.endTransmission();
  29.  
  30.   Serial.print("Tlacitko1 = ");
  31.   Serial.print(stavTlacitka1);
  32.   Serial.println(" =>");
  33.  
  34.   delay(100);
  35.  
  36.  
  37.  }
  38.  
  39.  else if (stavTlacitka2 == HIGH) {
  40.  
  41.   Wire.beginTransmission(1);
  42.   delay(100);
  43.   Wire.write('b');
  44.   delay(100);
  45.   Wire.endTransmission();
  46.  
  47.   Serial.print("Tlacitko2 = ");
  48.   Serial.print(stavTlacitka2);
  49.   Serial.println(" =>");
  50.  
  51.   delay(100);
  52.  
  53.  
  54.  }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement