daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. long randNumber;
  2.  
  3. void setup(){
  4.   Serial.begin(9600);
  5.   pinMode(2, OUTPUT);
  6.   pinMode(3, OUTPUT);
  7.  
  8.   // if analog input pin 0 is unconnected, random analog
  9.   // noise will cause the call to randomSeed() to generate
  10.   // different seed numbers each time the sketch runs.
  11.   // randomSeed() will then shuffle the random function.
  12.   randomSeed(analogRead(0));
  13. }
  14.  
  15. void loop() {
  16.  
  17.   digitalWrite(2, HIGH);
  18.   digitalWrite(3, HIGH);
  19.  
  20.   randNumber = random(1, 11);
  21.   Serial.println(randNumber);
  22.  
  23.  
  24. if (randNumber == 2) {
  25.   digitalWrite(2, LOW);
  26.   digitalWrite(3, LOW);
  27. }
  28.  
  29. else if(randNumber != 2) {
  30.   digitalWrite(2, HIGH);
  31.   digitalWrite(3, HIGH);
  32. }
  33.  
  34.  
  35.   delay(1000);
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top