Circuit 2

Hello together
first of all english is, like u will see soon, not my motherlanguage so iam sure iam gonna do here and there some mistakes i still hope u will understand everything iam writting. My name is Marco and iam new here and trying to learn the programming with Arduino Uno. I already have some knowlege about programming with C++. But i already have problems with the 2ten Circuit of the Handbook for beginners.
The Problem is, that the light is shining constantly and nothing is changing when iam turning the potentiometer. First i thought maybe my potentiometer is broken but when i tryed circuit 6 its didnt work too. I think something is wrong with my A0 Analog In pin. I hope someone can help me.

used code [Edit]:

int sensorPin=0;
int ledPin = 13;
void setup()
{
int sensorValue;
}

void loop()
{
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin,HIGH);
delay(sensorValue);
digitalWrite(ledPin,LOW);
delay(sensorValue);
}

i was bulding the equiment exactly like on the following picture

PS: I already tryed turning the potentiometer like its written in the handbook under troubleshooting

Really hope someone can help me
Thanks anyway for reading

Regards
Marco

The code should be in the loop() function which is run continuously instead of the setup()function which is just run once after every start-up or reset. Also the setup function should contain a pinMode() function call setting the ledpin as an output.

You need to understand what void setup() and void loop() do. setup() will only run once whereas loop() runs constantly unless stuck in another loop.

Try this.

void setup()
{
  pinMode(13, OUTPUT);
}

void loop()
{
  int sensorValue;
  sensorValue = analogRead(sensorPin);
  digitalWrite(ledPin,HIGH);
  delay(sensorValue);
  digitalWrite(ledPin,LOW);
  delay(sensorValue);
}

Iam sorry it was my fault the problem is still the same i was writting the code wrong from my secound screen the code iam actually using is:

int sensorPin = 0;
int ledPin = 13;

void setup()
{
pinMode(ledPin,OUTPUT);
}

void loop()
{
int sensorValue;
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin,HIGH);
delay(sensorValue);
digitalWrite(ledPin,LOW);
delay(sensorValue);
}

I didnt write this code by my own i mean i understand it but its not working the LED is shining constantly
thanks for the answeres!

pinMode(ledPin**;** OUTPUT);

Spaces allow you to see your errors. You have a semicolon where you need a comma.

Ah yes sorry again...mistake by writting from the secound screen sorry. The code is working i mean i can make it on the board so the problem is not that iam doing this kind of mistakes i think the problem is "deeper"
thanks for the correction

The Led is always on, now is it solid or does it flicker? Maybe you wired your potentiometer incorrectly or perhaps your potentiometer is defective.

Disconnect your external LED and see what the onboard LED next to pin 13 does by itself.

Thank u for u answere first.
The LED is constant on. No shaking or something like that even when iam turning on the potentiometer.
The LED on the Board next to the pin 13 is shining constant too.
I made the LED away ==> The LED on the Board next to the pin13 is still shining constant.
I made the LED back on his position and made the Cable of A0 Analog In away ==> the LED and the LED on the board is blinking on and off.

I made a small video that u can see it by ur own i hope it will help to understand my problem
thank u again for ur help

regards
Marco

Are you using the 5v or 3.3v for the pot?
Do an analog read of your pin to see what is happening.

int sensorPin = A0;
int ledPin = 13;

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

void loop()
{
int sensorValue;
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
digitalWrite(ledPin,HIGH);
delay(sensorValue);
digitalWrite(ledPin,LOW);
delay(sensorValue);
}

Iam using 5V for the port.
I tryed your code but i really have no idea how to read it. I used serial monitor to "show" me something i hope this is right. Now its showing me "B"s or rectangels and all of them very quick...

Hi,

If you are posting code or error messages, use "code" tags: How to use this forum - please read. - Installation & Troubleshooting - Arduino Forum

This will help with the formatting and presentation of your sketch.

Tom... :slight_smile:

What is the number in the lower right corner of your serial monitor? 9600 or something else?

I made a restart of my PC now when iam clicking on serial monitor its showing me zeros and the number lower right corner is 9600 Baud

When iam changing it in 300 Baud its showing me the B´s and the rectangels

Leave it at 9600. dont change it.

Ok but what should i do know? I already finished circuit 3 and 4 without a problem and i really start having the feeling that the A0 analog IN doesnt work... how can i find out if its the potentiometer or the analog in? Dont wanna send the Arduino UNO back with the result it wasnt the fault of the board. Could it be wrong treiber? (i dont know if treiber is used in english i mean the software u have to install that the PC can understand the hardware)

Marco

Do you have a voltmeter?
Better yet, hook your external LED directly to the middle pin on the pot with the other end of the LED to ground and see if you can control the brightness of it.

Very good idea! Em yes i can controll the LED with the poti...that means its the A0 port? You got n tricky idea to find that out too?
thanks again =)

You bet I do.

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.println(analogRead(A0));
  delay(500); 
}

Tada!

Iam sorry i dont understand^^ what excatly should i do with this code? Or better question what should this code show me and where?

Open a new blank sketch, then simply copy the new code in it, upload it to the arduino and open the Serial monitor. If you see numbers increase as you turn the pot, then the pot is good.