Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino - Remote control (RF-TX)
#1
Brick 
Došao sam na ideju da izradim daljinsku kontrolu sa Arduinom i RF setom na 433MHz, ali kao i na svakom projektu problemi su prisutni...

Evo kod koji sam našao na netu i malo ga prepravio, ali to nisam dobro odradio pa imam problema sada.

Transmitter:
Code:
//transmitter
int inPin1 = 2;
int inPin2 = 3;
int inPin3 = 4;
int inPin4 = 5;

byte data;
boolean state;

void setup()
{

pinMode(inPin1,INPUT);
pinMode(inPin2,INPUT);
pinMode(inPin3,INPUT);
pinMode(inPin4,INPUT);
Serial.begin(9600);
data='0';
}

void loop()
{
while(1)
{
state=digitalRead(inPin1);
if(state==LOW)
data='A';
else
data='B';
Serial.write(data);

state=digitalRead(inPin2);
if(state==LOW)
data='C';
else
data='D';
Serial.write(data);

state=digitalRead(inPin3);
if(state==LOW)
data='E';
else
data='F';
Serial.write(data);

state=digitalRead(inPin4);
if(state==LOW)
data='G';
else
data='H';
Serial.write(data);
}

}

Receiver:
Code:
//receiver
byte incoming;

int ledPin1 = 8;
int ledPin2 = 6;
int ledPin3 = 4;
int ledPin4 = 2;

void setup()
{
Serial.begin(9600);
pinMode(ledPin1,OUTPUT);
pinMode(ledPin2,OUTPUT);
pinMode(ledPin3,OUTPUT);
pinMode(ledPin4,OUTPUT);
}

void loop()
{
while(1)
{
while(Serial.available())
{
incoming=Serial.read();
if(incoming=='B')
digitalWrite(ledPin1,HIGH);
else
digitalWrite(ledPin1,LOW);
}

while(Serial.available())
{
incoming=Serial.read();
if(incoming=='D')
digitalWrite(ledPin2,HIGH);
else
digitalWrite(ledPin2,LOW);
}

while(Serial.available())
{
incoming=Serial.read();
if(incoming=='F')
digitalWrite(ledPin3,HIGH);
else
digitalWrite(ledPin3,LOW);
}

while(Serial.available())
{
incoming=Serial.read();
if(incoming=='H')
digitalWrite(ledPin4,HIGH);
else
digitalWrite(ledPin4,LOW);
}
}
}

.
Problem je sledeći, kada transmitter šalje poruke u slovima kao što je u kodu, dok ispiše sve četiri komande receiver čita po redu komande i na izlazu ledice mi trepere kako ih on čita? Kako bi to mogao riješiti ali da kod opet u jednu ruku ostane jednostavan, bar za mene?
Ako sam promašio mjesto teme molio bih moderatore da oni premjeste na odgovarajuće mjesto.
Reply


Messages In This Thread
Arduino - Remote control (RF-TX) - by Makso - 09-10-2016, 01:02 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-10-2016, 04:03 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-10-2016, 06:20 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 05:43 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 06:40 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:00 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:07 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:33 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:46 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 08:09 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 03:11 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-26-2016, 04:52 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 06:31 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-26-2016, 06:57 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 07:14 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-26-2016, 08:54 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 10:01 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-27-2016, 10:38 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 12:40 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 09-27-2016, 03:40 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 09-27-2016, 04:37 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 05:32 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 09-27-2016, 07:58 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 08:07 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-27-2016, 09:09 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-27-2016, 10:33 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 10:44 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-28-2016, 08:48 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-28-2016, 11:45 AM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-28-2016, 06:33 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-28-2016, 06:48 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-28-2016, 07:11 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-28-2016, 07:19 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-29-2016, 09:32 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-03-2016, 10:46 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 10-06-2016, 09:32 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-06-2016, 10:20 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-20-2016, 10:59 AM
RE: Arduino - Remote control (RF-TX) - by npejcic - 10-20-2016, 04:10 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-20-2016, 06:17 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 10-20-2016, 08:16 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-18-2017, 03:28 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-18-2017, 07:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-18-2017, 08:04 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-19-2017, 01:20 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-18-2017, 09:29 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-18-2017, 11:24 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-19-2017, 09:25 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-19-2017, 12:08 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-19-2017, 07:31 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-27-2017, 04:31 PM
RE: Arduino - Remote control (RF-TX) - by vsavic - 02-27-2017, 04:43 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-27-2017, 04:56 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 02-27-2017, 07:34 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-27-2017, 10:56 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 02-28-2017, 01:59 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-28-2017, 09:17 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 03-26-2017, 11:41 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-15-2017, 11:16 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 12-28-2017, 10:37 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 12-29-2017, 12:29 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 12-29-2017, 01:05 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-03-2018, 12:40 AM
RE: Arduino - Remote control (RF-TX) - by mikikg - 01-03-2018, 08:28 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-05-2018, 05:49 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-05-2018, 11:38 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-06-2018, 12:06 AM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-06-2018, 12:12 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-06-2018, 12:33 AM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-06-2018, 08:45 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-06-2018, 08:34 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-17-2018, 08:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-18-2018, 06:05 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-19-2018, 06:38 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-19-2018, 11:19 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-21-2018, 03:28 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-21-2018, 01:26 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-21-2018, 05:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 01:12 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 01:40 AM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 01:54 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 02:03 AM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 10:33 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 01:51 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 03:19 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 03:50 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-22-2018, 04:00 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 09:12 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 10:48 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 11:12 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 01:22 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 01:20 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-23-2018, 03:18 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-23-2018, 07:20 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-23-2018, 07:26 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 03:53 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 10:21 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 11:47 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 04:12 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 04:46 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 05:20 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 05:52 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-24-2018, 06:30 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-24-2018, 09:37 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-25-2018, 02:01 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-25-2018, 01:54 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-25-2018, 02:35 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-26-2018, 12:34 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-26-2018, 12:57 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-26-2018, 04:05 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-26-2018, 09:08 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-31-2018, 09:02 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-31-2018, 09:39 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-31-2018, 10:14 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-02-2018, 06:27 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-02-2018, 09:35 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-02-2018, 11:33 PM
RE: Arduino - Remote control (RF-TX) - by mikikg - 02-03-2018, 10:14 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-03-2018, 02:13 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-03-2018, 08:59 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 05-26-2018, 12:03 PM

Forum Jump:


Users browsing this thread: 7 Guest(s)