This is why tinkerCAD is horrible for simulating Arduino


Negative RPM?
Analog Voltage?

Just playing with it because I was bored and that happened. Going to just buy some more real hardware. :slight_smile:

Are you sure it isn't spinning backwards?

1 Like

No idea.
I will check.

It spins one way than the other.
Not spinning backwards.
It shows negative RPM because I connected motor red to negative and vice versa.
But still, Motors don’t work that way in real life!

Many real-life motors do spin the opposite direction when you connect a negative voltage to them. And tinkerCAD might simply be showing a negative RPM since it's going backwards from the "normal" direction. I see nothing wrong with that.

3 Likes

What I meant was the negative RPM. But it sort of makes sense now.
Thanks.
What is weird is the analog voltage……

What value did you write to the PWM pin with analogWrite? It looks like it might be 89 (5V * 89/256 = 1.738...V). The analog voltmeter might be smoothing the PWM to an analog voltage.

2 Likes

No idea.
Was using a modified Fade example.
Could be anything between 250 and 20.


// C++ code
//





  


/*

By V205
Thanks to Adafruit
analogWrite(LEDPin, 5); 

*/

int PWMLevel = 105;
int increment = 5;
const int  updateInterval = 10;      // interval between updates
unsigned long lastUpdate; // last update of pitch

void setup() {
  // put your setup code here, to run once:'
  Serial.begin(115200);
  Serial.println(F("Non blocking PWM example"));
  pinMode(LEDPin, OUTPUT); 
}

void loop() {
  // put your main code here, to run repeatedly:

    UpdatePWMLevel();
}
void UpdatePWMLevel()
  {
    if((millis() - lastUpdate) > updateInterval)  // time to update
    {
      lastUpdate = millis();
      PWMLevel += increment; 
      analogWrite(LEDPin, PWMLevel); 
      Serial.println(PWMLevel);
      if(PWMLevel >= 250|| PWMLevel <= 20) // Pitch boundaries
      {
        // reverse pitch direction
        increment = -increment;
      }
    }
  }


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