Getting full Voltage out of PIN ~10 (Edited)

Salutations.

The code below allows me, when having introduced 99 on SerialMonitor, to obtain the Output on Digital Pin PWM of 255.

However, when i measure the voltage, in respect to arduino ground, on the ~10 I get only 0,77V.

What am i doing wrong? Shouldn't it give me 4,75V if not 5V?

#include <SoftwareSerial.h>

int motorPin = 10;
int DT = 99;
char protoDT[3];
//boolean houveAtual = false;

void readProtoDT();
void readProtoDT();

void setup()
{
  Serial.begin(9600);
  pinMode(motorPin, OUTPUT);
}


void loop() 
{
  readProtoDT();
  convertProtoDT();

  analogWrite(motorPin, DT);
  //Serial.println(protoDT);
  Serial.println(DT);  
}

  
void readProtoDT()
{ 
  char rcvd;
  int indx = 0;
  while (Serial.available()>0)
  {
    rcvd = Serial.read();
    
    if (rcvd != '\n' && indx < 2 ) 
    {
      protoDT[indx] = rcvd;
      indx++;
    } 
    else
      protoDT[2]='\0';
  }
}


void convertProtoDT()
{
  char *ptr;
  DT = (strtol(protoDT,&ptr,10)/(float)99)*255;
}

It seems I have to write stuff in order to find out the solutions.

I am getting the 5V alright.

What happens is that I measured the difference in potential through the Base-Emitter of the transistor being used, which has a drop of 0,7V.

So what this means is...? I need to use a resistor in series with Base I order to draw more from the arduino, to power the Motor higher?

So what this means is...? I need to use a resistor in series with Base I order to draw more from the arduino, to power the Motor higher?

No what it means is that you need to look in the learning zone and find out how to control a motor with a transistor. The resistor is required but you are not drawing current "from the Arduino" to power the motor.

Mark

I get it now, of course, the Arduino has a limit of around 50mA (Leonardo board), that's why the top value I get is 55mA.

So I'll need to, either select the transistor according to this in order to open the tap to the fullest, or use the arduino to power a 2nd transistor which will control current being fed into the base of the main one, like a Darlington.

let's try that learning zone.

No! The current for the motor does NOT code from the Aduino pin! The current goes from the +ve through the motor, through the transistor to ground. The transistor is used as an on/off switch. The resistor (between the Arduino pin and the transistor base) is need to make the transistor function as a switch.

Mark

Use a 150 ohm resistor between Arduino pin and the base.

Note you have already exceeded the absolute maximum ratings of the chip and it may
be partially damaged - disconnect everything from the pin and check it works with just
the voltmeter before proceeding...