Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Arduino Kodiranje

[es] :: Elektronika :: Mikrokontroleri :: Arduino Kodiranje

[ Pregleda: 1054 | Odgovora: 5 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Dzoni28
Nikola Tasevski
SURČIN

Član broj: 346091
Poruke: 3
79.101.120.*



Profil

icon Arduino Kodiranje16.02.2021. u 00:38 - pre 38 meseci
Pozdrav, treba mi pomoc oko kodiranja arduina, da li neko moze da mi pomogne ?
 
Odgovor na temu

SASA M.
Pripyat

Član broj: 32850
Poruke: 3180
*.dynamic.sbb.rs.



+370 Profil

icon Re: Arduino Kodiranje16.02.2021. u 08:02 - pre 38 meseci
Verovatno ce ti neko pomoći ako budeš napisao šta te muči.
 
Odgovor na temu

ZAS011
Uzgajivač šargarepe izakuće
Vanuatu

Član broj: 288510
Poruke: 4543

ICQ: 8713400
Sajt: www.justfuckinggoogleit.c..


+530 Profil

icon Re: Arduino Kodiranje16.02.2021. u 08:28 - pre 38 meseci
Počneš nešto da radiš i kada ti zapne naćiće se neko da ti pomogne.
--
Make no mistake between my personality and my attitude.
My personality is who I am.
My attitude depends on who you are.
 
Odgovor na temu

Dzoni28
Nikola Tasevski
SURČIN

Član broj: 346091
Poruke: 3
79.101.120.*



Profil

icon Re: Arduino Kodiranje16.02.2021. u 10:32 - pre 38 meseci
E ovako, pravim projekat parking senzora za garazu, plan mi je da stavim po 3 ili 4 ultrasonic senzora sa obe strane, znaci da se automobili parkiraju jedan pored drugog. Trenutno imam 2 senzora i releje s kojima kontrolisem belu led traku. Kasnije cu ubaciti RGB traku i to znam kako da iskodiram. Interesuje me kako da stopiram loop ili releje koji se nalaze na jednoj strani? A da se pokrene opet kad krene auto da se pomera. Evo mog koda:

//----------------------------------------------------------------------------------------------------------------------
#define trigPin1 9 //pin number 9
#define echoPin1 8 // we'll use this pin to read the signal from the first sensor
#define Relay1 6 // I/O digital ( we will use pin 6 to command an Relay (on/off))
//----------------------------------------------------------------------------------------------------------------------

//define the pins that we will use for the second ultrasonic sensor
//----------------------------------------------------------------------------------------------------------------------
#define trigPin2 10
#define echoPin2 11
#define Relay2 7
//----------------------------------------------------------------------------------------------------------------------

//used variables
//----------------------------------------------------------------------------------------------------------------------
long duration, distance, UltraSensor1, UltraSensor2; //we'll use these variable to store and generate data

char data;
String SerialData="";
//----------------------------------------------------------------------------------------------------------------------

//Make the setup of your pins
//----------------------------------------------------------------------------------------------------------------------
void setup()
{// START SETUP FUNCTION
Serial.begin (9600); // we will use the serial data transmission to display the distance value on the serial monitor

// setup pins first sensor
pinMode(trigPin1, OUTPUT); // from where we will transmit the ultrasonic wave
pinMode(echoPin1, INPUT); //from where we will read the reflected wave
pinMode(Relay1, OUTPUT); // from where we will control the LED

//setup pins second sensor
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
pinMode(Relay2, OUTPUT);


//inisialize LED status

}// END SETUP FUNCTION


//write the code in the loop function
void loop()
{
// START THE LOOP FUNCTION
SonarSensor(trigPin1, echoPin1); // look bellow to find the difinition of the SonarSensor function
UltraSensor1 = distance; // store the distance in the first variable
SonarSensor(trigPin2,echoPin2); // call the SonarSensor function again with the second sensor pins
UltraSensor2 = distance; // store the new distance in the second variable

while(Serial.available())
{
delay(10);
data=Serial.read();
SerialData+=data;
}

if(SerialData=="display distance")
{
// display the distances on the serial monitor for the first sensor
//----------------------------------------------------------------------------------------------------------------------
Serial.print("distance measured by the first sensor: ");
Serial.print(UltraSensor1);
Serial.println(" cm");
//----------------------------------------------------------------------------------------------------------------------

//display the distance on the serial monitor for the second sensor
//----------------------------------------------------------------------------------------------------------------------
Serial.print("distance measured by the second sensor: ");
Serial.print(UltraSensor2);
Serial.println(" cm");
Serial.println("---------------------------------------------------------------------------------------------------------");
//----------------------------------------------------------------------------------------------------------------------
}

SerialData="";
// make condition to control the LEDs
if(UltraSensor1 <=15)// if distance is less than 15 Cm turn the LED ON
{
digitalWrite(Relay1,LOW);
}
else // else turn the LED OFF
{
digitalWrite(Relay1,HIGH);
}

// do the same thing for second sensor
if(UltraSensor2 <=15)
{
digitalWrite(Relay2,LOW);
}
else
{
digitalWrite(Relay2,HIGH);
}
if(UltraSensor1 <=5)// Blink led
{
delay(200);
digitalWrite(Relay1,HIGH);
delay(200);

}

if(UltraSensor2 <=5) //Blink led
{
delay(200);
digitalWrite(Relay2,HIGH);
delay(200);
}

}//END LOOP FUNTION

// SonarSensor function used to generate and read the ultrasonic wave
void SonarSensor(int trigPinSensor,int echoPinSensor)//it takes the trigPIN and the echoPIN
{
//START SonarSensor FUNCTION
//generate the ultrasonic wave
//----------------------------------------------------------------------------------------------------------------------
digitalWrite(trigPinSensor, LOW);// put trigpin LOW
delayMicroseconds(2);// wait 2 microseconds
digitalWrite(trigPinSensor, HIGH);// switch trigpin HIGH
delayMicroseconds(10); // wait 10 microseconds
digitalWrite(trigPinSensor, LOW);// turn it LOW again
//----------------------------------------------------------------------------------------------------------------------

//read the distance
//----------------------------------------------------------------------------------------------------------------------
duration = pulseIn(echoPinSensor, HIGH);//pulseIn funtion will return the time on how much the configured pin remain the level HIGH or LOW; in this case it will return how much time echoPinSensor stay HIGH
distance= (duration/2) / 29.1; // first we have to divide the duration by two
}// END SonarSensor FUNCTION
 
Odgovor na temu

ZAS011
Uzgajivač šargarepe izakuće
Vanuatu

Član broj: 288510
Poruke: 4543

ICQ: 8713400
Sajt: www.justfuckinggoogleit.c..


+530 Profil

icon Re: Arduino Kodiranje16.02.2021. u 20:12 - pre 38 meseci
I jesi li probao da prepraviš išta u ovom pronađenom programu?
--
Make no mistake between my personality and my attitude.
My personality is who I am.
My attitude depends on who you are.
 
Odgovor na temu

Dzoni28
Nikola Tasevski
SURČIN

Član broj: 346091
Poruke: 3
*.adsl-a-1.sezampro.rs.



Profil

icon Re: Arduino Kodiranje16.02.2021. u 20:26 - pre 38 meseci
Već sam prepravio i dodao ovo za blinkanje kad je distanca manja od 5, ali nemam ideju kako da stopiram releje kad se distanca ne menja.
 
Odgovor na temu

[es] :: Elektronika :: Mikrokontroleri :: Arduino Kodiranje

[ Pregleda: 1054 | Odgovora: 5 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.