Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. const unsigned int LED_BIT0 = 13;
  2. const unsigned int LED_BIT1 = 12;
  3. const unsigned int LED_BIT2 = 11;
  4. const unsigned int BAUD_RATE = 9600;
  5. long result;
  6.  
  7. void setup() {
  8. pinMode(LED_BIT0, OUTPUT);
  9. pinMode(LED_BIT1, OUTPUT);
  10. pinMode(LED_BIT2, OUTPUT);
  11.  
  12. randomSeed(analogRead(A0));
  13. result = random(1,7);
  14. output_result(result);
  15.  
  16. Serial.begin(BAUD_RATE);
  17. }
  18.  
  19. void loop() {
  20. stampa_numero();
  21. }
  22.  
  23. void stampa_numero() {
  24. Serial.print("Numero: ");
  25. Serial.println(result);
  26. }
  27.  
  28. void output_result(const long result) {
  29. digitalWrite(LED_BIT0, result & B001);
  30. digitalWrite(LED_BIT1, result & B010);
  31. digitalWrite(LED_BIT2, result & B100);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement