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!

ok,
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() {
pinMode(5,OUTPUT);
}

void loop() {
digitalWrite(5,HIGH);
delay(5000);
digitalWrite(5,LOW);
delay(5000);
}
////////////////////////////////////////
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:

1 Like

What program did you use to make that diagram?

in this site.
https://www.tinkercad.com/things/hUFz3N8Kg6d-grand-hango-jaiks/editel?tenant=circuits

1 Like

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?

1 Like

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

1 Like

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

1 Like

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.

1 Like

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.

like:
if(temperature){
digitalWrite(motor,HIGH);
digitalWrite(led,LOW);
}else{ digitalWrite(motor,LOW);
digitalWrite(led,HIGH);}

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()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(motor1, OUTPUT);
pinMode(ledpin2, OUTPUT);
}

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

This is the right one, You can use alternatively code from here: https://www.instructables.com/id/Temperature-Sensor-Tutorial/

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.