Error while analog reading/writing

Hello, i've learned the language by 'myself' (this site, google, and reading what you guys write). and i'm trying a simple program, to imply into something more complex afterwards. but i seem to have an error.

when i turn the variable resistor from one side to another, voltage starts to build up from 0-5V in about 1/4 of the actual rotation, then drops to 0 and starts going up again, 4 times in total. so basicly instead of using the full range of my variable resistor, it uses only 1/4 of the range, but 4 times. I think everything is connected right on my hardware, but i can't seem to find what could be wrong with my code either.

I've connected one end of the variable resistor to +5V, the other end to 0V and the variable pin to A0 on my arduino uno R3. i connect output 3 (a PWM output) to a resistor, and that resistor to the base of my transistor. (i calculated the value of the resistor with the saturation voltage and current.)

int pot = A0;
int trans = 3;
int sensorValue = 0;

void setup() {

void loop() {
  sensorValue = analogRead(pot); /*read the value of the variable resistor*/
  map(sensorValue,0,1023,0,254); /*change the 0-1023 analog input range to 0-254 pwm output range*/
  analogWrite(trans, sensorValue);/*write the pwm output on the transistor output*/

What do you see if you print the value of sensorValue ? Where do you think that the output from the map() function is going ?

You're not reassigning the value returned by "map()", so you're writing the value you read (0...1023) to the PWM output, so it will wrap, four times, as you have observed.