SHARE
TWEET

Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- long randNumber;
- void setup(){
- Serial.begin(9600);
- pinMode(2, OUTPUT);
- pinMode(3, OUTPUT);
- // if analog input pin 0 is unconnected, random analog
- // noise will cause the call to randomSeed() to generate
- // different seed numbers each time the sketch runs.
- // randomSeed() will then shuffle the random function.
- randomSeed(analogRead(0));
- }
- void loop() {
- digitalWrite(2, HIGH);
- digitalWrite(3, HIGH);
- randNumber = random(1, 11);
- Serial.println(randNumber);
- if (randNumber == 2) {
- digitalWrite(2, LOW);
- digitalWrite(3, LOW);
- }
- else if(randNumber != 2) {
- digitalWrite(2, HIGH);
- digitalWrite(3, HIGH);
- }
- delay(1000);
- }
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.