My code won't work

I'm coding a program on my Arduino Leonardo (littleBits) to make a loop so when it gets input from pin a0 it will turn on the rest of my bits and when it gets input from a1 it will ajust the speed of amount its on for

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color](){
  [color=#CC6600]pinMode[/color](5, [color=#006699]OUTPUT[/color] ) ;
  [color=#CC6600]pinMode[/color](0, [color=#006699]INPUT[/color] ) ;
  [color=#CC6600]pinMode[/color](1, [color=#006699]INPUT[/color] ) ;

[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color](){
  [color=#CC6600]digitalWrite[/color](5, [color=#006699]HIGH[/color]);
  [color=#CC6600]delay[/color]( (1024 - [color=#CC6600]analogRead[/color](A1)) );
  [color=#CC6600]digitalWrite[/color](5, [color=#006699]LOW[/color]);


The error I get is: avrdude: ser_open(): can't open device "\.\COM5": The system cannot find the file specified.

avrdude: ser_send(): write error: sorry no info avail

Any help on this? I'm a noob so I'm not the best but I can understand basic code. (FYI I'm 12 so don't give any too complicated answers but I'm smart for my age).

I think thats the one where you have to unplug the arduino, click upload, then reconnect, and click upload again.

12 years old, good for you. Do you have your board selected in the IDE? Do you have the com port selected?

You attach your code using the code tags, look at the stickey at the top of this forum.

Is this your program?

void setup(){
  pinMode(5, OUTPUT) ;
  pinMode(0, INPUT) ;
  pinMode(1, INPUT ) ;

void loop(){
  digitalWrite(5, HIGH);
  delay( (1024 - analogRead(A1)) );
  digitalWrite(5, LOW);

If that's right, you may want to replace your pinMode expressions with

pinMode(5, OUTPUT);
pinMode(A1, INPUT);

To get the analog readings, although that probably doesn't have anything to do with your uploading errors Also, you may want to put your errors in the code tags so that they are easier to read. (I'm still learning this myself... ) :)

Thank you, I'm trying your legowave and thatnks for the help

void setup(){ pinMode(5, OUTPUT ) ; pinMode(A1, INPUT ) ; }

void loop(){ digitalWrite(5, HIGH); delay( (1024 - analogRead(A1)) ); digitalWrite(5, LOW); delay(500); }

Here is my updated code. I still get the exact same error. Any reason why?

ClanScorpia: Here is my updated code. I still get the exact same error. Any reason why?

The problem doesn't seem to be the code itself, but rather the uploading. Do you have the correct device port set?