randomSeed()

randomSeed()

void randomSeed(unsigned int seed)

seed 使 0

random() randomSeed() 使 analogRead()

使 randomSeed()

0ADC
long randNumber;
void setup() {
pinMode(0, INPUT_ANALOG);
randomSeed(analogRead(0));
}
void loop() {
randNumber = random(300);
SerialUSB.println(randNumber);
delay(50);
}


License and Attribution: Portions of this page were adapted from the Arduino Reference Documentation, which is released under a Creative Commons Attribution-ShareAlike 3.0 License.
leafLabs, LLC.