Hey guys, noob to all this, I'm having some major trouble with this project, like the I2C simply isn't even turning on - even in the tinkercad simulation! And the 12V DC fan simply wont turn on as well, i have no idea what to do at this point so I thought some of you vets can correct any mistakes. Personally, I really don't see any issues with this but I think i may have short circuited the whole thing since when i tried plugging in my 12V DC adapter it fried, before that I was using a 12V AC adapter (I know it was dumb and i didn't realize it) . I got a new I2C and another 12V DC adapter this time.
Also for some quick background on the topic: I wanted to make a temperature based fan controller using the arduino uno along with an LM35 sensor, as well as a transistor to control the fan's speed. The lcd was supposed to show the temperature and the LED to signify any overheating (above 40 degrees celsius)
Also heres the full code -noob at c too ![]()
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); //0x27 being the address here
const int tempPin = A0;
const int fanPin = 9;
const int ledPin = 6;
void setup() {
lcd.begin(16, 2);
lcd.backlight();
pinMode(fanPin, OUTPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
// To read and smooth the temp
int total = 0;
const int samples = 10; //Read temp sensor 10 times to smooth them out by averaging
for (int i = 0; i < samples; i++) {
total += analogRead(tempPin);
delay(5);
}
float avg = total / (float)samples;
float voltage = avg * (5.0 / 1023.0);
float tempC = voltage * 100.0; //converting voltage to degrees celsius
// To display on LCD
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(tempC, 1);
lcd.print((char)223); //degree symbol
lcd.print("C ");
// Fan Control Logic
int pwm = map(tempC, 25, 45, 0, 255); //mapping temp range from 25-45 Celsius with 25 off and 45 full to 0-255 PWM
pwm = constrain(pwm, 0, 255); //so the fan doesn't go outside this range
if (pwm > 0 && pwm < 100) pwm = 100; //forces the fan to move immediately
analogWrite(fanPin, pwm); //sends the PWM value to the transistor
digitalWrite(ledPin, tempC > 40 ? HIGH : LOW); //if temp greater than 40 degrees , LED turns on
delay(500);
}
I'll include the images of both the project irl, and the simulation, not sure if they'll actually upload since I'm new here but i hope they will
Please inform me if the images aren't clear enough, i can also send the simulation's schematic if needed














