Answer is: 13rd pin is INTEGREATED with LED_BUILTIN. (On clone Arduino Uno, I DO NOT KNOW What is in the original arduino.) So, You can't disintegrate the LED_BUILTIN in Pin 13.
/* Mert Arduino and Raspberry Pi - Line Following Robot */
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Define Pins
int greenLedPin = 12;
int mic;
int ENA = 3; // Enable Pin of the Right Motor (must be PWM)
int IN1 = 1; // Control Pin
int IN2 = 2;
int ENB = 6; // Enable Pin of the Left Motor (must be PWM)
int IN3 = 4;
int IN4 = 5;
int redLedPin = 0;
int yellowLedPin = 7;
// LCD Config
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Speed of the Motors
#define ENASpeed 100
#define ENBSpeed 100
int Sensor1 = 0;
int Sensor2 = 0;
int Sensor3 = 0;
int Sensor4 = 0;
void setup() {
pinMode(redLedPin, OUTPUT);
pinMode(greenLedPin, OUTPUT);
pinMode(yellowLedPin, OUTPUT);
// Serial
Serial.begin(115200);
// LCD functions
lcd.init();
lcd.backlight();
// Pin modes
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(Sensor1, INPUT);
pinMode(Sensor2, INPUT);
pinMode(Sensor3, INPUT);
pinMode(Sensor4, INPUT);
}
void loop() {
// Use analogWrite to run motor at adjusted speed
analogWrite(ENA, ENASpeed);
analogWrite(ENB, ENBSpeed);
// Read the Sensor if HIGH (BLACK Line) or LOW (WHITE Line)
Sensor1 = digitalRead(8);
Sensor2 = digitalRead(9);
Sensor3 = digitalRead(10);
Sensor4 = digitalRead(11);
// Set conditions for FORWARD, LEFT and RIGHT
if (Sensor4 == HIGH && Sensor3 == HIGH && Sensor2 == LOW && Sensor1 == LOW) {
// LCD Write "Left Motor"
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Left Motor");
// Turn LEFT
// motor A Backward
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
// motor B Forward
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
// LED'leri güncelle
digitalWrite(redLedPin, HIGH);
digitalWrite(greenLedPin, LOW);
digitalWrite(yellowLedPin, LOW);
Serial.println("Left Motor");
} else if (Sensor4 == LOW && Sensor3 == LOW && Sensor2 == HIGH && Sensor1 == HIGH) {
// LCD Write "Right Motor"
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Right Motor");
// Turn RIGHT
// motor A Forward
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
// motor B Backward
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
// LED'leri güncelle
digitalWrite(redLedPin, LOW);
digitalWrite(greenLedPin, HIGH);
digitalWrite(yellowLedPin, LOW);
Serial.println("Right Motor");
} else {
// LCD Write "Forward Motor"
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Forward Motor");
// FORWARD
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
// LED'leri güncelle
digitalWrite(redLedPin, LOW);
digitalWrite(greenLedPin, LOW);
digitalWrite(yellowLedPin, HIGH);
Serial.println("Forward Motor");
}
}
Plus, I do not use pin 13 (at all.)
Some of the code was generated by GPT-4o (AI),
That is NOT my code. Added led functions, so please remove.
All the power of the internet and ChatGPT gets it wrong... and forgot about pins 14, 15, 1,6, 17, 18 and 19.
I do not understand your question(s).
You will have to analyse the schematic of the clone.
I have original Unos (R3) as well as a SparkFun RedBoard (it's more than a clone but demonstrates the principle).
On the SparkFun, pin 13 directly drives the LED. If you don't use pin 13, the pin is an input and high impedance; as a result it can not drive the LED and the LED is off.
On official Unos, the LED is driven by a LMV358. Its input is high impedance and is connected to pin 13 which is also high impedance. As a result, the connection between pin 13 and the LMV358 can pick up noise which results in the LED being on.
If you do not want the LED on pin 13 to be on, you should set pin 13 as an output; it should default to LOW and the LED will be off.
same with clone.
14 and 15 etc. are on the Arduino Mega. I know that.
And, I will recomend using Arduino Mega if you're making a BIG project. Mega is the best to use. (Not for learning + You have 16 ANALOG PINS and 52 or 50 digital pins. The led driver is hard to find.)
Ok, Same with the clone UNO, (CH340) The LED driver will high impediance (if you connected) and the LED will turn off
on in so little light
I can explain. It's Mert make the code. I connect 1, nothing happens. That's the TX pin. So, that pin is The uploader. 0 pin is communacitation, code uplading, EVEN For receiveing Serial on pc.
CH340 is not a led driver
Pins 0 & 1 together make up the UART interface. Do not separate it.
I would advise you to read books and documentation instead of communicating with artificial intelligence, which very often produces, I must say, complete nonsense.
CH340 = Arduino clone. I meant LMV358 Led driver and the clone. It's the same with Official UNO.
Yes. Definetly. So you can't upload code when 0 is inserted.
I don't understand this. Is it an output from GhatGPT?
By the way, LMV358 is also not a Led driver
no.
are you sure???
@arduino_uno534
Please explain, what's your problem with pin13 and how did you solved it with this topic?
read 2nd comment
2nd comment has TX/RX being used to control a motor and an LED. See 3rd comment.
