Make many random data sensor in arduino uno

hi there, i try to learn how to make dummy data in arduino uno, this is my code ive try:

long randNumber;

void setup() {

  // 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.

void loop() {
  // print a random number from 0 to 299
  randNumber = random(300);

  // print a random number from 10 to 19
  randNumber = random(10, 20);

   if (randNumber>70){
     Serial.println("Temperature is greater than 70"); 
else {
     Serial.println("Temperature is less than or equal to 70"); 


serial monitor result:
serial plotter result:

so, how to generate a lot of random data of various sensors?,,anyone have any other code for literacy?i try to make random data for voltage sensor,current sensor,motor pwm,torque.


azhar megantara

1 Like

Doesn't seem very likely, does it?

Please remember to use code tags when posting code

What is the problem ?

Generate as many values as you want one after the other then display them. At worst repeat the code to generate the values as many times as needed but better, use a single function to do it

What have you tried ?

@ridhoazhar313, your topic has been moved to a more suitable location on the forum. Introductory tutorials is for tutorials, not questions; feel free to write a tutorial once you have mastered your issue :wink:

Please edit your post, select all code and click the </>button to apply code tags; next save your post

What is your objective other than to create noise?

are you trying to develop a simulator for a motor?

current depends on the resistance of the motor, BEMF and applied voltage

BEMF depends on the motor speed (rpm) which depends on the mechanical load and torque that accelerates the motor over time.

the motor toque depends on various motor parameters

I have edited my code above. thanks.:slight_smile:

I think yes, because of covid-19 I can't go to the laboratory at this time. and I need random data for these sensors.

ive already edited for my code,thanks :slight_smile:

But you're still testing a number that can never exceed 19, to see if it is greater than 70.
That's a complete waste of time.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.