Help in coding please


Let me make a diagram based on the one he provided in the video description.

Here’s my Diagram. I hope it helps!


lets start :

  1. without coding take the motor and connected with the 5V pin and GND , if the motor working we tested without code ,to check if the arduino can give the motor enough amber to work.

2)try to connect the motor with pin 5 and GND,
and but this code :
void setup() {

void loop() {
this code make the motor turn on and off every 5 sec.
just to check the motor with pin 5.

but if from step 1 the motor not working in this case, the arduino cant give the motor enough Amber.
in this case you should connect the motor with external battery.

using the above code just different with connect.

in this case we just check the motor working in witch case.

then return the full code and test your project.

if you have any question ,i am here waiting you to give me another update :stuck_out_tongue_winking_eye:


What program did you use to make that diagram?


in this site.


I figured, thanks. Question, does Tinkercad ag with you sometimes?


i don’t understand your question, but i know this site about year a go,

this site help you to try some project without buy anything.

if i answer your question that’s good if not asked it to me again?


I’ve been using that website for a few years but i’ve been having this problem where every so often I get a lag and my computer as well as the website drastically slow down. I was asking if you’ve faced these issues once before.


seriously i don’t use it so much , but no i don’t have any issue, i use it to test some sensor i don’t have it, but maybe if all this issue if you use it a long time


What do I need the servo for? and do I change anything in the code?


If you want to make alight and motor(fan) you don’t need a servo motor.
but if you want make a servo like open and close the window you can use it.
and what happened in your motor ??is it working??
if you want to add a servo motor yes you should change a little in your code.


I’m not sure why you need the servo. I didn’t watch the video. I simply viewed the schematics and made them easier to read. The servo motor was part of the program was it not.


i already finished the code but my problem is that when the temperature reaches my wanted one its either led lights up or the motor works. Never both. How do i fix it? Other than that its working well. But i keep changing the wires and only one of them works accordingly but not both together. How do i make them both work together the red led and the motor?


dear shamsa,

to make the system work led or motor,
when the system should turn on the led make the motor off the right the led on,

and when the system need the motor on and the light off,
the same way turn the light off.

}else{ digitalWrite(motor,LOW);

that’s make one of them ON.


I already wrote the code. There’s nothing wrong with it. I think its just the wires? Help me fix them. I need the motor and red led to work together.


can you send the code just to check?
and did you check the polarity for the led??


float tempC;
float sum=0,avg=0;
int tempPin = A0;
int ledPin = 4; //connected to pin4
int motor1 = 5;//connected to pin 5
int ledpin2 = 2;
//setup function
void setup()
pinMode(ledPin, OUTPUT);
pinMode(motor1, OUTPUT);
pinMode(ledpin2, OUTPUT);

void loop()
for(int i=0;i<10;i++){
tempC = analogRead(tempPin);
tempC = (5.0tempC100.01)/1024.0;
if (avg < 115)
digitalWrite(ledPin, HIGH);
digitalWrite(motor1, HIGH);
digitalWrite(ledpin2, LOW);
digitalWrite(ledPin, LOW);
digitalWrite(motor1, LOW);
digitalWrite(ledpin2, HIGH);


This is the right one, You can use alternatively code from here:

Want to learn then click here.


I just want to fix mine


please help me! I need to fix it now.


i am very sorry to late in answer,

first i need from you to check something:

first: put wire between the GND line.
then put the red LED the white wire in 5V in arduino to check if the led working.
then send to me the result please.